Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

THIS IS CODE FOR A C# CLASS I\'M WORKING ON I WOULD LIKE YOU TO PUT COMMENTS for

ID: 3597441 • Letter: T

Question

THIS IS CODE FOR A C# CLASS I'M WORKING ON I WOULD LIKE YOU TO PUT COMMENTS for each page TO HELP ME UNDERSTAND BETTER

// Right here

// And here

// And here please

namespace TDP.SurveyMaker. BL 9 10 : public class CQuizzer 12 13 14 15 public Guid Id get; set; public CActivator Activator get; set; ) public Guid AnswerId { get; set; public cQuizzer() 17 19 20 21 public cQuizzer(Guid id) 23 25 26 27 28 29 30 31 32 public void Insert() QuestionsDataContext oDc new QuestionsDataContext(); tb!Response response new tb!Response(); response. Id = Guid . NewGuid(); //response . ActivationId this.Activation1d; response . Answer|d 34 35 this . Answer!d; 37 this.Id -response.Id;

Explanation / Answer

Comments on screen:

Screen 1:

Insert method uses QuestionDataContext, context class for the CRUD operation (here its used for insertion). Here response of tblResponse type is assigned with the CQuizzer class’s guid id and answered values and then the response object is passed on for the insertion. Finally, the insertion is committed using the submitChanges method of the context create at the beginning of this method. Generally, this pattern is used in Entity framework for the CRUD operations.

Screen 2:

If statement is just to make sure the instance guid is unique indeed, and then questionDataContext is instantiated. Next response is loaded with response which matches with instance Guid using a lambda expression. FirstorDefault(), makes sure that we get only one record back not multiple and a default value in case no matching record was found.

If found the current Id is assigned with response id found above.

Then loadById method of the CActivator type of used to pass the response.activationid

Screen 3:

This method takes in activationcode as parameter.

If() condition makes sure that activationcode is not empty or null.

QuestionDataContext is instantiated like before and used to find the matching activation result using same firstordefault extension method as above.

If activation result is found successfully then instance id is updated with that, and then we call the activator load by id method and pass the activation result’s id found above.