Click here to Skip to main content
14,766,405 members
Home » Discussions » C#
   

C#

 
AnswerRe: .NET5 publish selfcontained: issue with App.config Pin
Richard Deeming17-Nov-20 18:46
mveRichard Deeming17-Nov-20 18:46 
GeneralRe: .NET5 publish selfcontained: issue with App.config Pin
Super Lloyd17-Nov-20 19:12
MemberSuper Lloyd17-Nov-20 19:12 
AnswerRe: .NET5 publish selfcontained: issue with App.config Pin
Gerry Schmitz17-Nov-20 21:46
mveGerry Schmitz17-Nov-20 21:46 
GeneralRe: .NET5 publish selfcontained: issue with App.config Pin
Super Lloyd17-Nov-20 21:52
MemberSuper Lloyd17-Nov-20 21:52 
GeneralRe: .NET5 publish selfcontained: issue with App.config Pin
Gerry Schmitz17-Nov-20 21:59
mveGerry Schmitz17-Nov-20 21:59 
GeneralRe: .NET5 publish selfcontained: issue with App.config Pin
Super Lloyd17-Nov-20 22:16
MemberSuper Lloyd17-Nov-20 22:16 
GeneralRe: .NET5 publish selfcontained: issue with App.config Pin
Gerry Schmitz18-Nov-20 8:05
mveGerry Schmitz18-Nov-20 8:05 
QuestionHow to reference resource from Resources file Pin
Bootzilla3316-Nov-20 14:56
MemberBootzilla3316-Nov-20 14: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 22:45
mveRichard Deeming16-Nov-20 22:45 
GeneralRe: How to reference resource from Resources file Pin
Bootzilla3317-Nov-20 5:27
MemberBootzilla3317-Nov-20 5:27 
GeneralRe: How to reference resource from Resources file Pin
Richard Deeming17-Nov-20 5:30
mveRichard Deeming17-Nov-20 5:30 
QuestionVariable for number of days Pin
Member 1447460716-Nov-20 6:56
MemberMember 1447460716-Nov-20 6:56 
SuggestionRe: Variable for number of days Pin
Richard MacCutchan16-Nov-20 7:01
mveRichard MacCutchan16-Nov-20 7:01 
AnswerRe: Variable for number of days Pin
Gerry Schmitz16-Nov-20 7:58
mveGerry Schmitz16-Nov-20 7:58 
GeneralRe: Variable for number of days Pin
Richard Deeming16-Nov-20 22:41
mveRichard Deeming16-Nov-20 22:41 
GeneralRe: Variable for number of days Pin
Gerry Schmitz17-Nov-20 5:57
mveGerry Schmitz17-Nov-20 5:57 
GeneralRe: Variable for number of days Pin
Richard Deeming17-Nov-20 18:35
mveRichard Deeming17-Nov-20 18:35 
GeneralRe: Variable for number of days Pin
Gerry Schmitz17-Nov-20 21:52
mveGerry Schmitz17-Nov-20 21:52 
AnswerRe: Variable for number of days Pin
Richard Deeming16-Nov-20 22:43
mveRichard Deeming16-Nov-20 22:43 
GeneralRe: Variable for number of days Pin
pkfox18-Nov-20 22:11
professionalpkfox18-Nov-20 22:11 
QuestionChanging the properties of multiple labels in some kind of loop? Pin
Ron_UK16-Nov-20 5:55
MemberRon_UK16-Nov-20 5:55 
AnswerRe: Changing the properties of multiple labels in some kind of loop? Pin
Pete O'Hanlon16-Nov-20 6:00
mvePete O'Hanlon16-Nov-20 6:00 
GeneralRe: Changing the properties of multiple labels in some kind of loop? Pin
Ron_UK16-Nov-20 6:17
MemberRon_UK16-Nov-20 6:17 
AnswerRe: Changing the properties of multiple labels in some kind of loop? Pin
OriginalGriff16-Nov-20 6:06
mveOriginalGriff16-Nov-20 6:06 
GeneralRe: Changing the properties of multiple labels in some kind of loop? Pin
Ralf Meier16-Nov-20 6:16
professionalRalf Meier16-Nov-20 6: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.