public async Task <SharedLookUpResponse> UpdateExamPaperAsync(UpdateExam updateExam, int instituteId) { var examPapers = await iMSDbContext.ExamPapers.Where(x => x.InstituteId == instituteId && x.Id != updateExam.Id).ToListAsync(); var isDuplicated = examPapers.Any(x => x.PublisherName.ToLowerInvariant() == updateExam.PublisherName.ToLowerInvariant() && x.MappingId == updateExam.MappingId); if (isDuplicated) { return new SharedLookUpResponse() { HasError = true, ErrorType = SharedLookUpResponseType.Code, Message = "Duplicate info of Exmaination Paper, please use unique code" } } ; else { var examPaper = await iMSDbContext.ExamPapers.FirstAsync(x => x.Id == updateExam.Id); examPaper.PublisherName = updateExam.PublisherName; examPaper.Pages = updateExam.Pages; examPaper.Description = updateExam.Description; examPaper.MappingId = updateExam.MappingId; examPaper.AcademicYearId = updateExam.AcademicYearId; examPaper.InstituteId = updateExam.InstituteId; iMSDbContext.ExamPapers.Update(examPaper); await iMSDbContext.SaveChangesAsync(); return(new SharedLookUpResponse() { HasError = false, Message = "Exmaination Paper updated successfully" }); } }
public async Task <IActionResult> Put(Guid examId, [FromBody] UpdateExam command) { await _examService.UpdateAsync(examId, command.Name, command.Description); return(NoContent()); }
public async Task <IActionResult> UpdateGroupAsync([FromBody] UpdateExam updateComponentGroupAc) { if (string.IsNullOrEmpty(updateComponentGroupAc.PublisherName.Trim())) { return(Ok(new SharedLookUpResponse() { HasError = true, ErrorType = SharedLookUpResponseType.Name, Message = "Publisher name can't be null or empty" })); } else if (updateComponentGroupAc.MappingId == null) { return(Ok(new SharedLookUpResponse() { HasError = true, ErrorType = SharedLookUpResponseType.Name, Message = "Subject can't be null or empty" })); } else { var instituteId = await GetUserCurrentSelectedInstituteIdAsync(); if (await iMSDbContext.ExamPapers.AnyAsync(x => x.Id == updateComponentGroupAc.Id && x.InstituteId == instituteId)) { return(Ok(await examManagementRepository.UpdateExamPaperAsync(updateComponentGroupAc, instituteId))); } else { return(Ok(new SharedLookUpResponse() { HasError = true, ErrorType = SharedLookUpResponseType.Code, Message = "Exam Paper not found" })); } } }
protected void txt_update_Click2(object sender, EventArgs e) { string a, b, c, d, f, g, h; a = txt_question.Text; b = txt_1.Text; c = txt_2.Text; d = txt_3.Text; f = txt_4.Text; g = dd1.SelectedValue; if (g == "CHOICE A") { h = b; } else if (g == "CHOICE B") { h = c; } else if (g == "CHOICE C") { h = d; } else { h = f; } int count = 0; UpdateExam.update(name, id, a, b, c, d, f, h, ref count); txt_question.Text = ""; txt_1.Text = ""; txt_2.Text = ""; txt_3.Text = ""; txt_4.Text = ""; lbl_number.Text = count.ToString(); Response.Redirect("Showexam.aspx"); }