public Response <QuotationRegisterDto> Save(QuotationRegisterDto data, string token) {//REFACTOR Response <QuotationRegisterDto> obj = null; if (data.StatusQuotationId == StateQuotation.Potencial) { data.CommercialTerms = "Cotización Potencial"; } var hCliente = _global.rspClient("Quotation/", data, token); if (hCliente.StatusCode == System.Net.HttpStatusCode.BadRequest) { obj = new JavaScriptSerializer().Deserialize <Response <QuotationRegisterDto> >(hCliente.Content.ReadAsStringAsync().Result); } if (hCliente.IsSuccessStatusCode) { obj = new JavaScriptSerializer().Deserialize <Response <QuotationRegisterDto> >(hCliente.Content.ReadAsStringAsync().Result); } return(obj); }
public JsonResult Save(QuotationRegisterDto data) { #region TOKEN var sessione = (SessionModel)Session[Resources.Constante.SessionUsuario]; LoginDto oLoginDto = new LoginDto(); oLoginDto.v_UserName = sessione.UserName; oLoginDto.v_Password = sessione.Pass; var validated = _securityBL.ValidateAccess(oLoginDto); if (validated == null) { return(Json("", "application/json", Encoding.UTF8, JsonRequestBehavior.AllowGet)); } #endregion #region AUDIT data.InsertUserId = sessione.SystemUserId; data.ResponsibleSystemUserId = sessione.SystemUserId; #endregion var response = _quotationBL.Save(data, validated.Token); return(Json(response, "application/json", Encoding.UTF8, JsonRequestBehavior.AllowGet)); }
public ActionResult Index(EmailDto data, HttpPostedFileBase fileUploader) { if (ModelState.IsValid) { using (MailMessage mail = new MailMessage(Options.Email, data.to)) { if (!string.IsNullOrEmpty(data.cc)) { mail.CC.Add(data.cc); } mail.Subject = data.subject; mail.Body = data.body; if (fileUploader != null) { string fileName = Path.GetFileName(fileUploader.FileName); mail.Attachments.Add(new Attachment(fileUploader.InputStream, fileName)); } mail.IsBodyHtml = false; SmtpClient smtp = new SmtpClient(); smtp.Host = Options.Host; smtp.EnableSsl = Options.EnableSsl; NetworkCredential networkCredential = new NetworkCredential(Options.Email, Options.Password); smtp.UseDefaultCredentials = true; smtp.Credentials = networkCredential; smtp.Port = Options.Port; smtp.Send(mail); #region TOKEN var sessione = (SessionModel)Session[Resources.Constante.SessionUsuario]; LoginDto oLoginDto = new LoginDto(); oLoginDto.v_UserName = sessione.UserName; oLoginDto.v_Password = sessione.Pass; var validated = _securityBL.ValidateAccess(oLoginDto); if (validated == null) { return(Json("", "application/json", Encoding.UTF8, JsonRequestBehavior.AllowGet)); } #endregion var dataQuotation = new QuotationRegisterDto() { InsertUserId = sessione.SystemUserId, ResponsibleSystemUserId = sessione.SystemUserId, QuotationId = data.quotationId, StatusQuotationId = StateQuotation.Aceptada }; var dataQuotationMigrate = new QuotationMigrateDto() { QuotationId = data.quotationId }; var dataQuotationUpdate = new QuotationUpdateDto() { QuotationId = data.quotationId, StatusQuotationId = Convert.ToInt32(StateQuotation.Aceptada) }; var responseA = _quotationBL.Save(dataQuotation, validated.Token); var responseB = _quotationBL.MigrateQuotationToProtocols(dataQuotationMigrate, validated.Token); var responseC = _quotationBL.Update(dataQuotationUpdate, validated.Token); return(RedirectToAction("Index", "Quotation")); } } else { return(View()); } }