public async Task <bool> ReviewImage(ReviewCommentModel model) { var data = await _contex.UserModuleImages.FindAsync(model.UserModuleImageId); data.Comment = model.Comment; data.IsStatus = model.IsStatus; await _contex.SaveChangesAsync(); var sampleModuleImageCount = _contex.ModuleImages.Where(m => m.ModulId == model.ModuleId).Count(); var userModuleImageCount = _contex.UserModuleImages.Where(m => m.ModulId == model.ModuleId && m.UserId == model.UserId && m.IsStatus == 1).Count(); var userImageData = _contex.UserModuleImages.Where(m => m.ModulId == model.ModuleId && m.UserId == model.UserId).ToList(); var userTalksList = _contex.UserTalks.Where(m => m.ModuleId == model.ModuleId && m.UserId == model.UserId).ToList(); if (sampleModuleImageCount == userModuleImageCount) { for (int i = 0; i < userTalksList.Count(); i++) { userTalksList[i].IsModuleClear = 2; //this for module image submittion clear } } else { for (int i = 0; i < userTalksList.Count(); i++) { userTalksList[i].IsModuleClear = 1; //this for module image submittion pending } } return(await _contex.SaveChangesAsync() > 0 ? true : false); }
public async Task <ActionResult> AddReveiewImage(ReviewCommentModel model) { var data = await _facultyRepo.ReviewImage(model); var userEmail = await _userRepo.GetUserById(model.UserId); var facultiesData = await _facultyRepo.GetAllFaculty(); var facultyEmail = facultiesData.Where(f => f.Faculty_Id == model.FacultyId).First().Email; var moduleData = await _commonRepo.GetModuleById(model.ModuleId); var moduleName = moduleData.Name; var userModuleData = await _commonRepo.GetUserModuelImageById(model.UserModuleImageId); var moduleImageName = userModuleData.ImagePath; var moduleComment = userModuleData.Comment; string toAddress = string.Empty;//userEmail.Email.ToString(); string body = string.Empty; if (model.IsStatus == 1) // 1 for accept { string path = System.Web.HttpContext.Current.Server.MapPath("~/Views/EmailTemplates/ImageAccepted.html"); using (StreamReader reader = new StreamReader(path)) { body = reader.ReadToEnd(); } body = body.Replace("{modulename}", moduleName); // body = body.Replace("{moduleimage}", moduleImageName); body = body.Replace("{moduleComment}", moduleComment); // toAddress = userEmail.Email.ToString() + "," + facultyEmail.ToString(); toAddress = userEmail.Email.ToString(); _commonRepo.SendMail(toAddress, Sculptor.Gynac.Repository.Common.CommonRepository.EmailType.AcceptImage, "", body); } else if (model.IsStatus == 2)// 2 for rejected { string path = System.Web.HttpContext.Current.Server.MapPath("~/Views/EmailTemplates/ImageRejected.html"); using (StreamReader reader = new StreamReader(path)) { body = reader.ReadToEnd(); } body = body.Replace("{modulename}", moduleName); // body = body.Replace("{moduleimage}", moduleImageName); body = body.Replace("{moduleComment}", moduleComment); //toAddress = userEmail.Email.ToString() + "," + facultyEmail.ToString(); toAddress = userEmail.Email.ToString(); _commonRepo.SendMail(toAddress, Sculptor.Gynac.Repository.Common.CommonRepository.EmailType.RejectImage, "", body); } return(Json(new { success = true })); }