public ActionResult SaveCustomer(int title, string firstName, string lastname, string email, int gender, string dateofbirth, string postalcode, string address, string workphone, string mobile, int Id) { string FilePath = string.Empty; string fileName = string.Empty; if (Request.Files.Count > 0) { FilePath = ConfigurationManager.AppSettings["CmpCustomerFilePath"].ToString(); HttpPostedFileBase hpf = Request.Files[0] as HttpPostedFileBase; fileName = string.Format("{0}_{1}{2}", Path.GetFileNameWithoutExtension(hpf.FileName), DateTime.Now.ToString("ddMMyyyyhhmmss"), Path.GetExtension(hpf.FileName)); string path = Path.Combine(HttpContext.Server.MapPath(FilePath), fileName); hpf.SaveAs(path); } DateTime date = Convert.ToDateTime(dateofbirth); var data = _CompanyCustomerMethod.SaveCompanyCustomerData(fileName, title, firstName, lastname, email, gender, date, postalcode, address, workphone, mobile, Id, SessionProxy.UserId); if (!data) { return(Json("Error", JsonRequestBehavior.AllowGet)); } else { CompanyCustomerViewModel model = returnCustomerList(); return(PartialView("_partialCompanyCustomerList", model)); } }
public ActionResult AddEditCustomer(int Id) { string FilePath = ConfigurationManager.AppSettings["CmpCustomerFilePath"].ToString(); CompanyCustomerViewModel model = new CompanyCustomerViewModel(); model.Id = Id; var titleId = _otherSettingMethod.getSystemListByName("Title List"); var genderId = _otherSettingMethod.getSystemListByName("Gender List"); var titleLists = _otherSettingMethod.getAllSystemValueListByNameId(titleId.Id); var genderLists = _otherSettingMethod.getAllSystemValueListByNameId(genderId.Id); if (Id > 0) { var data = _CompanyCustomerMethod.getCompanyCustomerListById(Id); var title = _otherSettingMethod.getSystemListValueById(data.Title); var gender = _otherSettingMethod.getSystemListValueById(data.Gender); model.Id = data.Id; model.PhotoPath = data.PhotoPath; model.Title = data.Title; model.TitleValue = title.Value; model.FirstName = data.FirstName; model.LastName = data.LastName; model.Email = data.Email; model.Gender = data.Gender; model.GenderValue = gender.Value; model.DateOfBirth = data.DateOfBirth; model.Dob = String.Format("{0:dd-MM-yyy}", data.DateOfBirth); model.PostalCode = data.PostalCode; model.Address = data.Address; model.WorkPhone = data.WorkPhone; model.Mobile = data.Mobile; } else { foreach (var item in titleLists) { OtherSettingValueViewModel tableModel = new OtherSettingValueViewModel(); tableModel.Id = item.Id; tableModel.SystemListID = item.SystemListID; tableModel.Value = item.Value; model.titleList.Add(tableModel); } foreach (var item in genderLists) { OtherSettingValueViewModel tableModel = new OtherSettingValueViewModel(); tableModel.Id = item.Id; tableModel.SystemListID = item.SystemListID; tableModel.Value = item.Value; model.genderList.Add(tableModel); } model.Dob = String.Format("{0:dd-MM-yyy}", DateTime.Now); } return(PartialView("_partialAddCompayCustomer", model)); }
public ActionResult EditCustomer(int Id) { CompanyCustomerViewModel model = new CompanyCustomerViewModel(); var titleId = _otherSettingMethod.getSystemListByName("Title List"); var genderId = _otherSettingMethod.getSystemListByName("Gender List"); var titleLists = _otherSettingMethod.getAllSystemValueListByNameId(titleId.Id); var genderLists = _otherSettingMethod.getAllSystemValueListByNameId(genderId.Id); var data = _CompanyCustomerMethod.getCompanyCustomerListById(Id); var title = _otherSettingMethod.getSystemListValueById(data.Title); var gender = _otherSettingMethod.getSystemListValueById(data.Gender); model.Id = data.Id; model.PhotoPath = data.PhotoPath; model.Title = data.Title; model.TitleValue = title.Value; model.FirstName = data.FirstName; model.LastName = data.LastName; model.Email = data.Email; model.Gender = data.Gender; model.GenderValue = gender.Value; model.DateOfBirth = data.DateOfBirth; model.Dob = String.Format("{0:dd-MM-yyy}", data.DateOfBirth); model.PostalCode = data.PostalCode; model.Address = data.Address; model.WorkPhone = data.WorkPhone; model.Mobile = data.Mobile; foreach (var item in titleLists) { OtherSettingValueViewModel tableModel = new OtherSettingValueViewModel(); tableModel.Id = item.Id; tableModel.SystemListID = item.SystemListID; tableModel.Value = item.Value; model.titleList.Add(tableModel); } foreach (var item in genderLists) { OtherSettingValueViewModel tableModel = new OtherSettingValueViewModel(); tableModel.Id = item.Id; tableModel.SystemListID = item.SystemListID; tableModel.Value = item.Value; model.genderList.Add(tableModel); } if (data == null) { return(Json("Error", JsonRequestBehavior.AllowGet)); } else { return(PartialView("_partialAddCompayCustomer", model)); } }
public ActionResult SaveCompanyCustomer(CompanyCustomerViewModel model, ActionType actionType) { Logger.Debug("SaveCompanyCustomer|Action type: " + actionType); if (actionType == ActionType.Save) { try { if (CustomerBO.CheckIfIdCombinationExists( Int32.Parse(model.IdType), model.IdNumber, model.IdIssuedCountry, model.Id)) { TempData["MessageType"] = MessageType.Error; TempData["MessageDescription"] = CommonResources.MessageIdAlreadyExists; TempData["CustomerDetailModel"] = model; return(RedirectToAction("ViewCustomerDetails")); } ICompanyCustomerVO customer = (CompanyCustomerVO) CustomerMapper.Map(model, typeof(CompanyCustomerViewModel), typeof(CompanyCustomerVO)); customer.LastUpdateBy = User.Identity.Name; if (customer.Id == 0) { customer = CustomerBO.CreateCompanyCustomer(customer); } else { ICompanyCustomerVO sessionCustomer = (ICompanyCustomerVO)Session["SessionCustomer"]; customer = CustomerBO.UpdateCompanyCustomer(sessionCustomer, customer); } model = (CompanyCustomerViewModel) CustomerMapper.Map(customer, typeof(ICompanyCustomerVO), typeof(CompanyCustomerViewModel)); Session["SessionCustomer"] = customer; TempData["MessageType"] = MessageType.Success; TempData["MessageDescription"] = CommonResources.MessageSaveSuccess; } catch (Exception exception) { Logger.Debug("Exception encountered: " + exception.StackTrace); TempData["MessageType"] = MessageType.Error; TempData["MessageDescription"] = CommonResources.MessageSaveError + exception.Message; } TempData["CustomerDetailModel"] = model; return(RedirectToAction("ViewCompanyDetails")); } return(RedirectToAction("Welcome", "Home")); }
public ActionResult DeleteCustomer(int Id) { var data = _CompanyCustomerMethod.deleteCompanyCustomer(Id, SessionProxy.UserId); if (!data) { return(Json("Error", JsonRequestBehavior.AllowGet)); } else { CompanyCustomerViewModel model = returnCustomerList(); return(PartialView("_partialCompanyCustomerList", model)); } }
public CompanyCustomerViewModel returnCustomerList() { CompanyCustomerViewModel model = new CompanyCustomerViewModel(); //string FilePath = ConfigurationManager.AppSettings["CmpCustomerFilePath"].ToString(); var listData = _CompanyCustomerMethod.getAllCompanyCustomerList(); var titleId = _otherSettingMethod.getSystemListByName("Title List"); var genderId = _otherSettingMethod.getSystemListByName("Gender List"); var titleLists = _otherSettingMethod.getAllSystemValueListByNameId(titleId.Id); var genderLists = _otherSettingMethod.getAllSystemValueListByNameId(genderId.Id); foreach (var item in listData) { CompanyCustomerListViewModel tableModel = new CompanyCustomerListViewModel(); tableModel.Id = item.Id; tableModel.Name = item.FirstName + " " + item.LastName; tableModel.Phone = item.WorkPhone; tableModel.Email = item.Email; tableModel.Mobile = item.Mobile; model.customerList.Add(tableModel); } foreach (var item in titleLists) { OtherSettingValueViewModel tableModel = new OtherSettingValueViewModel(); tableModel.Id = item.Id; tableModel.SystemListID = item.SystemListID; tableModel.Value = item.Value; model.titleList.Add(tableModel); } foreach (var item in genderLists) { OtherSettingValueViewModel tableModel = new OtherSettingValueViewModel(); tableModel.Id = item.Id; tableModel.SystemListID = item.SystemListID; tableModel.Value = item.Value; model.genderList.Add(tableModel); } model.Dob = String.Format("{0:dd-MM-yyy}", DateTime.Now); return(model); }
public ActionResult customerList() { CompanyCustomerViewModel model = returnCustomerList(); return(PartialView("_partialCompanyCustomerList", model)); }