public async Task <ActionResult> Edit(LeadsEditViewModel updateLeads) { if (ModelState.IsValid) { tbl_crm_leads updatedLead = Mapper.Map <LeadsEditViewModel, tbl_crm_leads>(updateLeads); tbl_emp_info loggedInUserInfo = Utilities.GetLoggedInUserInfo(User.Identity.Name); int? loggedInUser = loggedInUserInfo.Emp_ID; updatedLead.Generated_By = loggedInUser; updatedLead.UpdatedAt = DateTime.Now; ResponseMessage responseMessage = await leadsManager.EditAsync(updatedLead).ConfigureAwait(false); if (responseMessage.Type == Constant.RESPONSE_MESSAGE_TYPE_SUCCESS) { return(Json(GeneralMessages.SAVE_SUCCESSFUL, JsonRequestBehavior.AllowGet)); } else { return(Json(GeneralMessages.SAVE_FAILED, JsonRequestBehavior.AllowGet)); } } else { return(Json(GeneralMessages.SAVE_FAILED, JsonRequestBehavior.AllowGet)); } }
public async Task <string> GetLeadEmailAsync(int?id) { tbl_crm_leads thisLead = await Db.tbl_crm_leads.FirstOrDefaultAsync(x => x.Lead_ID == id).ConfigureAwait(false); string email = thisLead.Email; return(email); }
public async Task <int> SaveProposalInfoAsync(tbl_crm_leads updateLead) { tbl_crm_leads thisLead = Db.tbl_crm_leads.FirstOrDefault(x => x.Lead_ID == updateLead.Lead_ID); thisLead.IsProposalSent = true; thisLead.Proposal_File = updateLead.Proposal_File; Db.Entry(thisLead).State = EntityState.Modified; int rowAffect = await Db.SaveChangesAsync().ConfigureAwait(false); return(rowAffect); }
public async Task <JsonResult> SaveProposalInfo(SendProposalViewModel viewModel) { var postedFileWithoutExtension = Path.GetFileNameWithoutExtension(viewModel.Attachment.FileName); viewModel.Proposal_File = Utilities.SaveImage(Server, viewModel.Attachment, postedFileWithoutExtension, Constant.FILE_PATH_FOR_LEADS_PROPOSAL); tbl_crm_leads updateLead = Mapper.Map <SendProposalViewModel, tbl_crm_leads>(viewModel); ResponseMessage responseMessage = await leadsManager.SaveProposalInfoAsync(updateLead).ConfigureAwait(false); if (responseMessage.Type == Constant.RESPONSE_MESSAGE_TYPE_SUCCESS) { var root = Server.MapPath(Constant.FILE_PATH_FOR_LEADS_PROPOSAL); var fileName = viewModel.Proposal_File; var path = Path.Combine(root, fileName); path = Path.GetFullPath(path); var message = new MailMessage(); message.To.Add(new MailAddress(viewModel.To)); // replace with valid value message.From = new MailAddress(ConfigurationManager.AppSettings["CRM_EMAIL_ADDRESS"]); // replace with valid value message.Subject = viewModel.Subject; message.Body = viewModel.Message; Attachment attachment = new Attachment(path, MediaTypeNames.Application.Octet); System.Net.Mime.ContentDisposition disposition = attachment.ContentDisposition; message.Attachments.Add(attachment); message.IsBodyHtml = true; using (var smtp = new SmtpClient()) { var credential = new NetworkCredential { UserName = ConfigurationManager.AppSettings["CRM_EMAIL_ADDRESS"], // replace with valid value Password = ConfigurationManager.AppSettings["CRM_EMAIL_PASSWORD"] // replace with valid value }; smtp.Credentials = credential; smtp.Host = "smtp.gmail.com"; smtp.Port = 587; smtp.EnableSsl = true; await smtp.SendMailAsync(message); } return(new JsonResult { Data = new { status = true } }); } else { return(new JsonResult { Data = new { status = false } }); } }
public bool isEmailExist(string email) { tbl_crm_leads hasRow = Db.tbl_crm_leads.FirstOrDefault(x => x.Email == email); if (hasRow == null) { return(false); } else { return(true); } }
public async Task <tbl_crm_leads> GetLeadByIdAsync(int?leadId) { if (leadId == null) { return(null); } else { tbl_crm_leads findLead = await leadsGateway.GetLeadByIdAsync(leadId).ConfigureAwait(false); return(findLead); } }
public async Task <int> EditAsync(tbl_crm_leads updatedLeads) { if (updatedLeads == null) { return(-1); } else { Db.tbl_crm_leads.AddOrUpdate(updatedLeads); int rowAffect = await Db.SaveChangesAsync().ConfigureAwait(false); return(rowAffect); } }
public async Task <int> AddAsync(tbl_crm_leads leads) { if (leads == null) { return(-1); } else { Db.tbl_crm_leads.Add(leads); int rowAffect = await Db.SaveChangesAsync().ConfigureAwait(false); return(rowAffect); } }
public async Task <int> DeleteByIdAsync(int?Id) { if (Id == null) { return(-1); } else { tbl_crm_leads thisLead = await GetLeadByIdAsync(Id).ConfigureAwait(false); thisLead.ActionType = Constant.DELETE; Db.Entry(thisLead).State = EntityState.Modified; int rowAffect = await Db.SaveChangesAsync().ConfigureAwait(false); return(rowAffect); } }
public async Task <ActionResult> View(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tbl_crm_leads viewLead = await leadsManager.GetLeadByIdAsync(id).ConfigureAwait(false); if (viewLead == null) { return(RedirectToAction("Index")); } else { return(PartialView(viewLead)); } }
public async Task <ActionResult> Edit(int?id) { if (id == null) { return(Json(false)); } else { tbl_crm_leads findLead = await leadsManager.GetLeadByIdAsync(id).ConfigureAwait(false); LeadsEditViewModel leadEditViewModel = Mapper.Map <tbl_crm_leads, LeadsEditViewModel>(findLead); leadEditViewModel.CountryList = await leadsManager.GetAllCountryAsync().ConfigureAwait(false); leadEditViewModel.SourceList = await leadsManager.GetAllSourceAsync().ConfigureAwait(false); return(PartialView(leadEditViewModel)); } }
public async Task <ResponseMessage> SaveProposalInfoAsync(tbl_crm_leads updateLead) { int rowAffect = await leadsGateway.SaveProposalInfoAsync(updateLead).ConfigureAwait(false); if (rowAffect <= 0) { return(new ResponseMessage { Type = Constant.RESPONSE_MESSAGE_TYPE_FAILED }); } else { return(new ResponseMessage { Type = Constant.RESPONSE_MESSAGE_TYPE_SUCCESS }); } }
public async Task <tbl_crm_leads> GetLeadByIdAsync(int?leadId) { if (leadId == null) { return(null); } else { tbl_crm_leads findRow = await Db.tbl_crm_leads.FirstOrDefaultAsync(x => x.Lead_ID == leadId).ConfigureAwait(false); if (findRow == null) { return(null); } else { return(findRow); } } }
public async Task <ResponseMessage> EditAsync(tbl_crm_leads updateLeads) { int rowAffect = await leadsGateway.EditAsync(updateLeads).ConfigureAwait(false); if (rowAffect <= 0) { return(new ResponseMessage { Type = Constant.RESPONSE_MESSAGE_TYPE_FAILED, Message = GeneralMessages.SAVE_FAILED }); } else { return(new ResponseMessage { Type = Constant.RESPONSE_MESSAGE_TYPE_SUCCESS, Message = GeneralMessages.SAVE_SUCCESSFUL }); } }
public async Task <ResponseMessage> AddAsync(tbl_crm_leads leads) { bool isEmailExist = leadsGateway.isEmailExist(leads.Email); int rowAffect = await leadsGateway.AddAsync(leads).ConfigureAwait(false); if (isEmailExist || rowAffect <= 0) { return(new ResponseMessage { Type = Constant.RESPONSE_MESSAGE_TYPE_FAILED, Message = GeneralMessages.SAVE_FAILED }); } else { return(new ResponseMessage { Type = Constant.RESPONSE_MESSAGE_TYPE_SUCCESS, Message = GeneralMessages.SAVE_SUCCESSFUL }); } }