public ActionResult EditFiles(int id, int?productId, ProcedureDocsType procedureDocsType) { if (id == 0 || productId == 0) { @ViewBag.Error = nameof(id); return(View("Error")); } try { var procedure = _procedureService.GetItem(id); var procedureDto = Mapper.Map <ProcedureDTO, ProcedureViewModel>(procedure); var productDto = _productService.GetProduct((int)productId); var product = Mapper.Map <ProductDTO, ProductViewModel>(productDto); _currentUser = GetCurrentUser(); procedureDto.ProductId = (int)productId; ViewBag.ProcedureDocsType = procedureDocsType; ViewBag.CountryId = productDto.CountryId; ViewBag.Country = product.Country; ViewBag.Product = product; ViewBag.User = _currentUser; ViewBag.DocsType = Enum.GetValues(typeof(ProcedureDocsType)); return(View(procedureDto)); } catch (Exception ex) { @ViewBag.Error = ex.ToString(); return(View("Error")); } }
public async Task SendEmailAboutAddFileProcedure(string procedureId, string productId, ProcedureDocsType procedureDocsType, string localFileName) { try { var prod = _productService.GetProduct(int.Parse(productId)); if (prod == null) { Logger.Log.Error($"{Resources.ErrorMessages.EmailNotSendCantFindProdToProc} ProcedureId={procedureId}"); return; } var product = Mapper.Map <ProductDTO, ShowProductModel>(prod); var productName = product.ProductName; var userEmailsToNotify = _countryService.GetCountryUsersEmailsViaName(product.Country); var body = new StringBuilder(); var subject = Resources.Email.SubjectProcedureUpdate.Replace("(name)", productName) + $" in {product.Country}"; body.Append(Resources.Email.BodyProcedureUpdate.Replace("(name)", productName) + $" in {product.Country}"); var bodyCompared = $"<strong>To procedure {procedureDocsType} added document:</strong> {localFileName}<br>"; if (!string.IsNullOrEmpty(bodyCompared)) { body.Append(":<br>"); body.Append(bodyCompared); body.Append(Resources.Email.Signature); var emailerDto = Mapper.Map <Emailer, EmailerDTO>(emailer); var proc = _procedureService.GetItem(int.Parse(procedureId)); if (proc.SubmissionDate >= DateTime.Parse("2018-11-11 00:00:00")) { await _emailService.SendEmailNotification(body.ToString(), subject, emailerDto, userEmailsToNotify, toSend); } } } catch (Exception ex) { var userName = User.Identity.Name; Logger.Log.Error($"{userName}: SenEmailAboutAddUpdateProduct() {ex.Message} "); } }