Click here to Skip to main content
15,880,608 members
Home / Discussions / C#
   

C#

 
AnswerRe: .NET5 publish selfcontained: issue with App.config Pin
Richard Deeming17-Nov-20 17:46
mveRichard Deeming17-Nov-20 17:46 
GeneralRe: .NET5 publish selfcontained: issue with App.config Pin
Super Lloyd17-Nov-20 18:12
Super Lloyd17-Nov-20 18:12 
AnswerRe: .NET5 publish selfcontained: issue with App.config Pin
Gerry Schmitz17-Nov-20 20:46
mveGerry Schmitz17-Nov-20 20:46 
GeneralRe: .NET5 publish selfcontained: issue with App.config Pin
Super Lloyd17-Nov-20 20:52
Super Lloyd17-Nov-20 20:52 
GeneralRe: .NET5 publish selfcontained: issue with App.config Pin
Gerry Schmitz17-Nov-20 20:59
mveGerry Schmitz17-Nov-20 20:59 
GeneralRe: .NET5 publish selfcontained: issue with App.config Pin
Super Lloyd17-Nov-20 21:16
Super Lloyd17-Nov-20 21:16 
GeneralRe: .NET5 publish selfcontained: issue with App.config Pin
Gerry Schmitz18-Nov-20 7:05
mveGerry Schmitz18-Nov-20 7:05 
QuestionHow to reference resource from Resources file Pin
Bootzilla3316-Nov-20 13:56
Bootzilla3316-Nov-20 13:56 
I have a bunch of messages in a Constants file that I want to convert all string constants for messages displayed to users to be moved to a localized/globalization resource file.

I created a Resources.resx file and I'm trying to figure out how to reference a resource in a controller. For example this resource in my Resources.resx file
internal static string ExamItemResponseAddSuccessfully {
           get {
               return ResourceManager.GetString("ExamItemResponseAddSuccessfully", resourceCulture);
           }
       }


I want to reference it in a controller POST action to replace the bolded reference to the string constant in the method below. How do I reference the resource above in the method below.

public async Task<IActionResult> CreateDorItemResponse(CreateEditDorItemResponseViewModel dorToCreateItemResponse, CancellationToken cancellationToken)
       {
           // Create a new Dor Item PacketResponse to receive the required properties from the view model
           var newDorItemResponse = new DorItemResponse();

           // Attempt to transfer the properties from the view model into the Dor
           if (ModelState.IsValid)
           {
               try
               {
                   //Get the item to return back to Edit Item page.
                   var item = await _dorService.GetItemAsync(dorToCreateItemResponse.ItemId, cancellationToken)
                       .ConfigureAwait(true);
                   // Save the Dor Item Response
                   _mapper.Map(dorToCreateItemResponse, newDorItemResponse);
                   newDorItemResponse.CreatedBy = User.Identity.Name;
                   newDorItemResponse.ModifiedBy = User.Identity.Name;
                   await _dorService.CreateEditItemResponse(newDorItemResponse, User.Identity.Name, cancellationToken).ConfigureAwait(true);
                   TempData.Put(TempDataKey.Dor.RESPONSE_ADD_MESSAGE, StatusMessageModel.Create(Constants.Dor.RESPONSE_ADD_SUCCESS, false));
                   return RedirectToAction(nameof(EditDorItem), new {id = item.ItemId, dorId = item.DorId});
               }
               catch (Exception)
               {
                   // Save failed, add an error message and reload the same page
                   TempData.Put(TempDataKey.Dor.RESPONSE_ADD_MESSAGE, StatusMessageModel.Create(Constants.Dor.RESPONSE_UPDATE_FAIL));
               }
           }
           // Validation failed, reload the same page
           return View(dorToCreateItemResponse);
       }

AnswerRe: How to reference resource from Resources file Pin
Richard Deeming16-Nov-20 21:45
mveRichard Deeming16-Nov-20 21:45 
GeneralRe: How to reference resource from Resources file Pin
Bootzilla3317-Nov-20 4:27
Bootzilla3317-Nov-20 4:27 
GeneralRe: How to reference resource from Resources file Pin
Richard Deeming17-Nov-20 4:30
mveRichard Deeming17-Nov-20 4:30 
QuestionVariable for number of days Pin
Member 1447460716-Nov-20 5:56
Member 1447460716-Nov-20 5:56 
SuggestionRe: Variable for number of days Pin
Richard MacCutchan16-Nov-20 6:01
mveRichard MacCutchan16-Nov-20 6:01 
AnswerRe: Variable for number of days Pin
Gerry Schmitz16-Nov-20 6:58
mveGerry Schmitz16-Nov-20 6:58 
GeneralRe: Variable for number of days Pin
Richard Deeming16-Nov-20 21:41
mveRichard Deeming16-Nov-20 21:41 
GeneralRe: Variable for number of days Pin
Gerry Schmitz17-Nov-20 4:57
mveGerry Schmitz17-Nov-20 4:57 
GeneralRe: Variable for number of days Pin
Richard Deeming17-Nov-20 17:35
mveRichard Deeming17-Nov-20 17:35 
GeneralRe: Variable for number of days Pin
Gerry Schmitz17-Nov-20 20:52
mveGerry Schmitz17-Nov-20 20:52 
AnswerRe: Variable for number of days Pin
Richard Deeming16-Nov-20 21:43
mveRichard Deeming16-Nov-20 21:43 
GeneralRe: Variable for number of days Pin
pkfox18-Nov-20 21:11
professionalpkfox18-Nov-20 21:11 
QuestionChanging the properties of multiple labels in some kind of loop? Pin
Ron_UK16-Nov-20 4:55
Ron_UK16-Nov-20 4:55 
AnswerRe: Changing the properties of multiple labels in some kind of loop? Pin
Pete O'Hanlon16-Nov-20 5:00
mvePete O'Hanlon16-Nov-20 5:00 
GeneralRe: Changing the properties of multiple labels in some kind of loop? Pin
Ron_UK16-Nov-20 5:17
Ron_UK16-Nov-20 5:17 
AnswerRe: Changing the properties of multiple labels in some kind of loop? Pin
OriginalGriff16-Nov-20 5:06
mveOriginalGriff16-Nov-20 5:06 
GeneralRe: Changing the properties of multiple labels in some kind of loop? Pin
Ralf Meier16-Nov-20 5:16
mveRalf Meier16-Nov-20 5:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.