public ActionResult List() { Logger.Info(_logMsg.Clear().SetPrefixMsg("InitSearch ActivityLog").ToInputLogString()); try { CustomerInfoViewModel custInfoVM = new CustomerInfoViewModel(); if (TempData["CustomerInfo"] != null) { custInfoVM = (CustomerInfoViewModel)TempData["CustomerInfo"]; TempData["CustomerInfo"] = custInfoVM; // Keep for change Tab } else { return(RedirectToAction("Search", "Customer")); } ActivityViewModel activityVM = new ActivityViewModel(); if (custInfoVM.CustomerId != null) { activityVM.CustomerInfo = custInfoVM; } _commonFacade = new CommonFacade(); _activityFacade = new ActivityFacade(); var subsType = custInfoVM.SubscriptType; var today = DateTime.Today; var month = new DateTime(today.Year, today.Month, 1); var numMonthsActivity = _commonFacade.GetNumMonthsActivity(); var activityStartDateValue = month.AddMonths(-1 * numMonthsActivity); //"2015-01-01".ParseDateTime("yyyy-MM-dd"); activityVM.SearchFilter = new ActivitySearchFilter { ActivityStartDateTime = activityStartDateValue.FormatDateTime(Constants.DateTimeFormat.DefaultFullDateTime), ActivityEndDateTime = DateTime.Now.FormatDateTime(Constants.DateTimeFormat.DefaultFullDateTime), CardNo = custInfoVM.CardNo, SubsTypeCode = subsType != null ? subsType.SubscriptTypeCode : null, PageNo = 1, PageSize = _commonFacade.GetPageSizeStart(), SortField = "ActivityID", SortOrder = "DESC" }; ViewBag.PageSize = activityVM.SearchFilter.PageSize; ViewBag.PageSizeList = _commonFacade.GetPageSizeList(); ViewBag.Message = string.Empty; return(View(activityVM)); } catch (Exception ex) { Logger.Error("Exception occur:\n", ex); Logger.Info(_logMsg.Clear().SetPrefixMsg("InitSearch ActivityLog").Add("Error Message", ex.Message).ToFailLogString()); return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(), this.ControllerContext.RouteData.Values["action"].ToString()))); } }
public ActionResult ChangeInfoData(string Id, string UserName, string Sex, string Email, string PhoneNumber) { using (var _context = TicketHubContext.Create()) { var user = _context.Users.Find(Id); user.UserName = UserName; user.Sex = Sex; user.Email = Email; user.PhoneNumber = PhoneNumber; _context.SaveChanges(); var info = new CustomerInfoViewModel() { Id = user.Id, Email = user.Email, PhoneNumber = user.PhoneNumber, UserName = user.UserName, Sex = user.Sex }; return(Json(info, JsonRequestBehavior.AllowGet)); } }
public ActionResult List(string encryptedString) { int?customerId = encryptedString.ToCustomerId(); Logger.Info(_logMsg.Clear().SetPrefixMsg("List Recommended Campaign").Add("CustomerId", customerId).ToInputLogString()); if (customerId == null) { return(RedirectToAction("Search", "Customer")); } try { CampaignViewModel campaignVM = new CampaignViewModel(); CustomerInfoViewModel custInfoVM = this.MappingCustomerInfoView(customerId.Value); campaignVM.CustomerInfo = custInfoVM; return(View(campaignVM)); } catch (Exception ex) { Logger.Error("Exception occur:\n", ex); Logger.Info(_logMsg.Clear().SetPrefixMsg("List Recommended Campaign").Add("Error Message", ex.Message).ToFailLogString()); return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(), this.ControllerContext.RouteData.Values["action"].ToString()))); } }
public bool AddCusstomer(CustomerInfoViewModel customerInfoVM) { try { CustomerInfo newcustomerInfo = new CustomerInfo() { CustomerName = customerInfoVM.CustomerName, CompanyCode = customerInfoVM.CompanyCode, Company = customerInfoVM.CompanyCode, Phone = customerInfoVM.Phone, Fax = customerInfoVM.Fax, Email = customerInfoVM.Email, Address = customerInfoVM.Address, CityID = customerInfoVM.CityID, Country = "Việt Nam", // tạm thời Bank = customerInfoVM.Bank, BankAccount = customerInfoVM.BankAccount, TaxCode = customerInfoVM.TaxCode, Remark = customerInfoVM.Remark, CreateBy = "admin", /// tạm thời - chỉnh sau CreateDate = SystemDefine.SystemDate.Date, UpdateBy = "", UpdateDate = SystemDefine.SystemDate.Date, CustomerTypeID = customerInfoVM.CustomerTypeID, StatusID = 1 }; ctr.Insert <CustomerInfo>(newcustomerInfo); return(true); } catch { } return(false); }
public ActionResult GetCustomerInfo() { var currentUserId = User.Identity.GetUserId(); var user = _context.Users.Find(currentUserId); var info = new CustomerInfoViewModel() { Id = user.Id, Email = user.Email, PhoneNumber = user.PhoneNumber, UserName = user.UserName, Sex = user.Sex, FavoriteShop = from s in _context.Shop join ufs in _context.UserFavoriteShop on s.Id equals ufs.ShopId select new ShopViewModel { Id = s.Id, ShopName = s.ShopName, ShopIntro = s.ShopIntro, City = s.City, District = s.District, Address = s.Address, Phone = s.Phone } }; return(Json(info, JsonRequestBehavior.AllowGet)); }
protected CustomerInfoViewModel MappingCustomerInfoView(int customerId) { using (var customerFacade = new CustomerFacade()) { // CustomerInfo CustomerEntity customerEntity = customerFacade.GetCustomerByID(customerId); CustomerInfoViewModel custInfoVM = new CustomerInfoViewModel(); custInfoVM.Account = customerEntity.Account; custInfoVM.AccountNo = customerEntity.AccountNo; custInfoVM.BirthDate = customerEntity.BirthDate; custInfoVM.CardNo = customerEntity.CardNo; custInfoVM.CreateUser = customerEntity.CreateUser; custInfoVM.CustomerId = customerEntity.CustomerId; custInfoVM.CustomerType = customerEntity.CustomerType; custInfoVM.Email = customerEntity.Email; custInfoVM.Fax = customerEntity.Fax; custInfoVM.FirstNameEnglish = customerEntity.FirstNameEnglish; custInfoVM.FirstNameThai = customerEntity.FirstNameThai; custInfoVM.LastNameEnglish = customerEntity.LastNameEnglish; custInfoVM.LastNameThai = customerEntity.LastNameThai; custInfoVM.FirstNameThaiEng = customerEntity.FirstNameThaiEng; custInfoVM.LastNameThaiEng = customerEntity.LastNameThaiEng; custInfoVM.PhoneList = customerEntity.PhoneList; custInfoVM.Registration = customerEntity.Registration; custInfoVM.SubscriptType = customerEntity.SubscriptType; custInfoVM.TitleEnglish = customerEntity.TitleEnglish; custInfoVM.TitleThai = customerEntity.TitleThai; custInfoVM.UpdateUser = customerEntity.UpdateUser; return(custInfoVM); } }
public bool UpdateCustomer(CustomerInfoViewModel customerInfoVM) { try { CustomerInfo customer = new CustomerInfo(); customer.CustomerID = customerInfoVM.CustomerID; customer = ctr.GetObject <CustomerInfo>(customer); if (customer != null) { customer.CustomerName = customerInfoVM.CustomerName; customer.Company = customerInfoVM.Company; customer.Phone = customerInfoVM.Phone; customer.Fax = customerInfoVM.Fax; customer.Email = customerInfoVM.Email; customer.Address = customerInfoVM.Address; customer.CityID = customerInfoVM.CityID; customer.Bank = customerInfoVM.Bank; customer.BankAccount = customerInfoVM.BankAccount; customer.TaxCode = customerInfoVM.TaxCode; customer.Remark = customerInfoVM.Remark; customer.UpdateBy = "Admin"; // tạm thời customer.UpdateDate = SystemDefine.SystemDate.Date; customer.CustomerTypeID = customerInfoVM.CustomerTypeID; customer.CompanyCode = customerInfoVM.CompanyCode; ctr.Update <CustomerInfo>(customer); return(true); } } catch { } return(false); }
/// <summary> /// Takes the info from a create customer view model and creates a new customer if that user name is not in use. /// </summary> /// <param name="createdPlayer">Create customer view model being created</param> /// <returns>Returns and logs in a new Customer info view model</returns> public CustomerInfoViewModel CreateUser(CreateCustomerViewModel createdPlayer) { StoreLocation favoriteStore = _repo.GetStoreByName(createdPlayer.StoreNameChosen); Customer customer = new Customer() { CustomerUserName = createdPlayer.CustomerUserName, CustomerPassword = createdPlayer.CustomerPassword, CustomerFName = createdPlayer.CustomerFName, CustomerLName = createdPlayer.CustomerLName, CustomerAge = createdPlayer.CustomerAge, CustomerBirthday = createdPlayer.CustomerBirthday, PerferedStore = favoriteStore }; // if null???? Customer newCustomer = _repo.CreateUser(customer); if (newCustomer == null) { return(null); } CustomerInfoViewModel newCustomerViewModel = _mapper.ConvertCustomerToCustomerInfoViewModel(newCustomer); return(newCustomerViewModel); }
private async Task <string> CreateCustomer(UserIdentityViewModel user, CustomerInfoViewModel model) { try { var customer = new Customer { FullName = model.FullName, CustomerCode = model.CustomerCode, Email = model.Email, Address = model.Address, Phone = model.PhoneNumber, SelectedReceiverId = model.SelectedReceiverId, CreatedOn = DateTimeOffset.Now, CreatedBy = user?.UserId }; _unitOfWork.CustomerRepository.Add(customer); await _unitOfWork.SaveChangeAsync(); return(customer.CustomerId.ToString()); } catch (Exception ex) { return("Save.Error"); } }
public bool AddCustomer(int idRequest) { List <RequestList> list = ctr.LoadListObject <RequestList>(); var result = list.FirstOrDefault(x => x.ID == idRequest); if (result != null) { // cập thật giá trị đã add customer result.Applied = true; ctr.Update <RequestList>(result); // new customer CustomerInfoViewModel newcustomerInfo = new CustomerInfoViewModel() { CustomerName = result.CustomerName, CompanyCode = result.CompanyCode, Company = result.CompanyCode, Phone = result.Phone, Fax = result.Fax, Email = result.Email, Address = result.Address, CityID = result.CityID, Country = "Việt Nam", // tạm thời CreateBy = "admin", // tạm thời - chỉnh sau CreateDate = SystemDefine.SystemDate.Date, UpdateDate = SystemDefine.SystemDate.Date, CustomerTypeID = result.CustomerTypeID, StatusID = 1 }; bool checkData = customerInfoData.AddCusstomer(newcustomerInfo); return(true); } return(false); }
public static CustomerInfoViewModel CustomerLogin(LoginViewModel request) { if (string.IsNullOrEmpty(request.CustomerID)) { throw new BusinessException("登录账号不能为空!"); } else if (string.IsNullOrEmpty(request.Password)) { throw new BusinessException("登录密码不能为空!"); } string newPassword = string.Empty; //string passwordSalt = string.Empty; //passwordSalt = LoginFacade.GetCustomerPasswordSalt(request.CustomerID); //request.Password = PasswordHelper.GetEncryptedPassword(HttpUtility.UrlDecode(request.Password.Replace("+", "%2b")) + passwordSalt); // [2014/12/22 by Swika]增加支持第三方系统导入的账号的密码验证 var encryptMeta = LoginFacade.GetCustomerEncryptMeta(request.CustomerID); try { request.Password = PasswordHelper.GetEncryptedPassword(HttpUtility.UrlDecode(request.Password.Replace("+", "%2b")), encryptMeta); var loginResult = LoginFacade.CustomerLogin(request.CustomerID, request.Password); if (null != loginResult) { CustomerInfoViewModel user = EntityConverter <CustomerInfo, CustomerInfoViewModel> .Convert(CustomerFacade.GetCustomerInfo(loginResult.SysNo), (s, t) => { t.RegisterTimeString = s.RegisterTime.ToString("yyyy年MM月dd日 HH:mm:ss"); t.AvtarImage = s.ExtendInfo.AvtarImage; t.AvtarImageDBStatus = s.ExtendInfo.AvtarImageDBStatus; }); if (user != null) { LoginFacade.UpdateLastLoginTime(user.SysNo); LoginUser lUser = new LoginUser(); lUser.UserDisplayName = user.CustomerName; lUser.UserID = user.CustomerID; lUser.UserSysNo = user.SysNo; lUser.RememberLogin = true; lUser.LoginDateText = DateTime.Now.ToString(); lUser.TimeoutText = DateTime.Now.AddMinutes(int.Parse(ConfigurationManager.AppSettings["LoginTimeout"].ToString())).ToString(); CookieHelper.SaveCookie <LoginUser>("LoginCookie", lUser); } System.Threading.Thread.Sleep(1000); return(user); } else { throw new BusinessException("登录失败,用户名或者密码错误!"); } } catch { throw new BusinessException("登录失败,用户名或者密码错误!"); } }
public CustomerViewModel() { customer = new Customer("Giedrius", 22); UpdateCommand = new CustomerUpdateCommand(this); childViewModel = new CustomerInfoViewModel(); this.LoadHomePageCommand = new DelegateCommand(o => this.LoadHomePage()); this.LoadSettingsPageCommand = new DelegateCommand(o => this.LoadSettingsPage()); this.LoadPlayPageCommand = new DelegateCommand(o => this.LoadPlayPage()); }
public ActionResult ShowList(int?id, string customerName) { ViewBag.showEdit = false; ViewBag.customerName = customerName; CustomerInfoViewModel viewModel = new CustomerInfoViewModel(); viewModel.客戶聯絡人s = this.repo客戶聯絡人.All().Where(x => x.客戶Id == id).OrderBy(x => x.姓名).ToPagedList(1, int.MaxValue); viewModel.客戶銀行資訊s = this.repo客戶銀行資訊.All().Where(x => x.客戶Id == id).OrderBy(x => x.銀行代碼).ToPagedList(1, int.MaxValue); return(PartialView("_ShowList", viewModel)); }
public ActionResult Details(Guid id) { CustomerInfoViewModel customerInfo = _logic.GetCustomerById(id); if (customerInfo == null) { ModelState.AddModelError("Failure", "Customer does not exist"); return(View(customerInfo)); } return(View(customerInfo)); }
public IActionResult CreateNewCustomer(CreateCustomerViewModel signUpView) { CustomerInfoViewModel customerCreated = _logic.CreateUser(signUpView); if (customerCreated == null) { ModelState.AddModelError("Failure", "Username already exists"); return(View("CreateCustomer")); } return(RedirectToAction("NewCustomer", customerCreated)); }
public IActionResult LoginCustomer(CustomerInfoViewModel newUser) { if (newUser == null) { ModelState.AddModelError("Failure", "Wrong Username and password combination!"); return(View("Index")); } HttpContext.Session.SetString("customerId", newUser.CustomerID.ToString()); HttpContext.Session.SetString("isAdmin", newUser.isAdmin.ToString()); return(RedirectToAction("Index", "Customer", newUser)); }
public ActionResult EditPlayer(CustomerInfoViewModel customerToEdit) { CustomerInfoViewModel editedCustomer = _logic.EditCustomer(customerToEdit); if (editedCustomer == null) { ModelState.AddModelError("Failure", "Customer does not exist"); return(View("Edit", editedCustomer)); } return(View("Details", editedCustomer)); }
public ActionResult List(int?customerId = null) { Logger.Info(_logMsg.Clear().SetPrefixMsg("List SR").ToInputLogString()); try { CustomerInfoViewModel custInfoVM = new CustomerInfoViewModel(); ViewBag.userId = this.UserInfo.UserId; if (TempData["CustomerInfo"] != null) { custInfoVM = (CustomerInfoViewModel)TempData["CustomerInfo"]; TempData["CustomerInfo"] = custInfoVM; // keep for change Tab } else { return(RedirectToAction("Search", "Customer")); } _commonFacade = new CommonFacade(); _customerFacade = new CustomerFacade(); SrViewModel srVM = new SrViewModel(); srVM.CustomerInfo = custInfoVM; if (custInfoVM.CustomerId.HasValue) { // SR list srVM.SearchFilter = new SrSearchFilter { CustomerId = custInfoVM.CustomerId.Value, PageNo = 1, PageSize = _commonFacade.GetPageSizeStart(), SortField = "CreateDate", SortOrder = "ASC" }; //srVM.SrList = _customerFacade.GetSrList(srVM.SearchFilter); ViewBag.PageSize = srVM.SearchFilter.PageSize; ViewBag.PageSizeList = _commonFacade.GetPageSizeList(); ViewBag.Message = string.Empty; } return(View(srVM)); } catch (Exception ex) { Logger.Error("Exception occur:\n", ex); Logger.Info(_logMsg.Clear().SetPrefixMsg("List SR").Add("Error Message", ex.Message).ToFailLogString()); return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(), this.ControllerContext.RouteData.Values["action"].ToString()))); } }
public ActionResult SRActivityList(ActivitySearchFilter searchFilter) { Logger.Info(_logMsg.Clear().SetPrefixMsg("Search SR Activity").ToInputLogString()); CustomerInfoViewModel custInfoVM = new CustomerInfoViewModel(); if (TempData["CustomerInfo"] != null) { custInfoVM = (CustomerInfoViewModel)TempData["CustomerInfo"]; TempData["CustomerInfo"] = custInfoVM; // keep for change Tab searchFilter.SrOnly = false; searchFilter.CustomerId = custInfoVM.CustomerId; } else { return(RedirectToAction("Search", "Customer")); } try { if (ModelState.IsValid) { _commonFacade = new CommonFacade(); _activityFacade = new ActivityFacade(); ActivityViewModel activityVM = new ActivityViewModel(); activityVM.SearchFilter = searchFilter; activityVM.ActivityList = _activityFacade.GetSRActivityList(searchFilter); ViewBag.PageSize = activityVM.SearchFilter.PageSize; ViewBag.PageSizeList = _commonFacade.GetPageSizeList(); Logger.Info(_logMsg.Clear().SetPrefixMsg("Search Activity").ToSuccessLogString()); return(PartialView("~/Views/Activity/_ActivityList.cshtml", activityVM)); } return(Json(new { Valid = false, Error = string.Empty, Errors = GetModelValidationErrors() })); } catch (Exception ex) { Logger.Error("Exception occur:\n", ex); Logger.Info(_logMsg.Clear().SetPrefixMsg("Search Activity").Add("Error Message", ex.Message).ToFailLogString()); return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(), this.ControllerContext.RouteData.Values["action"].ToString()))); } }
public ActionResult List(int?customerId = null) { try { CustomerInfoViewModel custInfoVM = new CustomerInfoViewModel(); if (TempData["CustomerInfo"] != null) { custInfoVM = (CustomerInfoViewModel)TempData["CustomerInfo"]; TempData["CustomerInfo"] = custInfoVM; // Keep for change Tab } else { return(RedirectToAction("Search", "Customer")); } Logger.Info(_logMsg.Clear().SetPrefixMsg("List Document").Add("CustomerId", custInfoVM.CustomerId).ToInputLogString()); _commonFacade = new CommonFacade(); _customerFacade = new CustomerFacade(); DocumentViewModel documentVM = new DocumentViewModel(); documentVM.CustomerInfo = custInfoVM; if (custInfoVM.CustomerId.HasValue) { // Attachment list documentVM.SearchFilter = new AttachmentSearchFilter { CustomerId = custInfoVM.CustomerId.Value, PageNo = 1, PageSize = _commonFacade.GetPageSizeStart(), SortField = "ExpiryDate", SortOrder = "DESC" }; documentVM.AttachmentList = _customerFacade.GetAttachmentList(documentVM.SearchFilter); ViewBag.CurrentUserId = this.UserInfo.UserId; // for check btnEdit btnDelete ViewBag.PageSize = documentVM.SearchFilter.PageSize; ViewBag.PageSizeList = _commonFacade.GetPageSizeList(); ViewBag.Message = string.Empty; } return(View(documentVM)); } catch (Exception ex) { Logger.Error("Exception occur:\n", ex); Logger.Info(_logMsg.Clear().SetPrefixMsg("List Customer").Add("Error Message", ex.Message).ToFailLogString()); return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(), this.ControllerContext.RouteData.Values["action"].ToString()))); } }
/// <summary> /// Searches for the customer and grabs them by their id /// </summary> /// <param name="id">customer id</param> /// <returns>Customer info view model based on customer id</returns> public CustomerInfoViewModel GetCustomerById(Guid id) { Customer customer = _repo.GetCustomerById(id); if (customer == null) { return(null); } CustomerInfoViewModel customerInfo = _mapper.ConvertCustomerToCustomerInfoViewModel(customer); return(customerInfo); }
public ResponseBaseViewModel <CustomerInfoViewModel> GetCustomerInfo() { int cid = this.GetCid(); ICustomerDomainFactory customerFactory = new CustomerDomainFactory(); var customerDomain = customerFactory.CreateDomainObj(); CustomerInfoModel customerInfoModel = customerDomain.GetCustomerInfo(cid); if (customerInfoModel.IsLock == "T") { throw new Exception("当前客户已经被冻结"); } if (customerInfoModel.IsDel == "T") { throw new Exception("当前客户已经被删除"); } CustomerInfoViewModel viewModel = Mapper.Map <CustomerInfoModel, CustomerInfoViewModel>(customerInfoModel); if (!string.IsNullOrEmpty(customerInfoModel.CorpId)) { ICorporationDomainFactory corporationDomainFactory = new CorporationDomainFactory(); var corpDomain = corporationDomainFactory.CreateDomainObj(); CorporationModel corporationModel = corpDomain.GetCorporationByCorId(customerInfoModel.CorpId); if (corporationModel.IsAmplitudeCorp == "T") { viewModel.IsCorpSystemCustomer = "T"; } else { viewModel.IsCorpSystemCustomer = "F"; } viewModel.CorpName = corporationModel.CorpName; } else { viewModel.IsCorpSystemCustomer = "F"; } ResponseBaseViewModel <CustomerInfoViewModel> v = new ResponseBaseViewModel <CustomerInfoViewModel>() { Flag = new ResponseCodeViewModel() { Code = 0, MojoryToken = this.GetToken() }, Data = viewModel }; return(v); }
public JsonResult EditCustomerInfo(CustomerInfoViewModel customerInfo) { string errorMsg; bool success = CustomerManager.UpdateCustomerPersonInfo(UserMgr.ReadUserInfo(), customerInfo, out errorMsg); JsonResult result = new JsonResult(); result.Data = new AjaxResult() { Success = success, Message = errorMsg, }; return(result); }
public async Task <string> SaveCustomer(UserIdentityViewModel user, CustomerInfoViewModel model) { string result = string.Empty; if (model.CustomerId == 0) { result = await CreateCustomer(user, model); } else { result = await UpdateCustomer(user, model); } return(result); }
public ActionResult List(string encryptedString) { int?customerId = encryptedString.ToCustomerId(); Logger.Info(_logMsg.Clear().SetPrefixMsg("List Contact").ToInputLogString()); try { if (customerId == null) { return(RedirectToAction("Search", "Customer")); } Logger.Info(_logMsg.Clear().SetPrefixMsg("List Contact").Add("CustomerId", customerId).ToInputLogString()); _commonFacade = new CommonFacade(); _customerFacade = new CustomerFacade(); CustomerContactViewModel contactVM = new CustomerContactViewModel(); CustomerInfoViewModel custInfoVM = this.MappingCustomerInfoView(customerId.Value); contactVM.CustomerInfo = custInfoVM; if (custInfoVM.CustomerId.HasValue) { // Contact list contactVM.SearchFilter = new ContactSearchFilter { CustomerId = custInfoVM.CustomerId.Value, PageNo = 1, PageSize = _commonFacade.GetPageSizeStart(), SortField = "CardNo", SortOrder = "ASC" }; contactVM.ContactList = _customerFacade.GetContactList(contactVM.SearchFilter); ViewBag.PageSize = contactVM.SearchFilter.PageSize; ViewBag.PageSizeList = _commonFacade.GetPageSizeList(); ViewBag.Message = string.Empty; } return(View(contactVM)); } catch (Exception ex) { Logger.Error("Exception occur:\n", ex); Logger.Info(_logMsg.Clear().SetPrefixMsg("List Contact").Add("Error Message", ex.Message).ToFailLogString()); return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(), this.ControllerContext.RouteData.Values["action"].ToString()))); } }
public IActionResult LoginCustomer(LoginViewModel loginView) { CustomerInfoViewModel customerLoggingIn = _logic.LoginUser(loginView); if (customerLoggingIn == null) { ModelState.AddModelError("Failure", "Wrong Username and password combination!"); return(View("Index")); } HttpContext.Session.SetString("customerId", customerLoggingIn.CustomerID.ToString()); HttpContext.Session.SetString("isAdmin", customerLoggingIn.isAdmin.ToString()); return(RedirectToAction("Index", "Customer", customerLoggingIn)); }
public async Task <IActionResult> Save([FromBody] CustomerInfoViewModel customer) { var result = await _customerService.SaveCustomer(CurrentUserIdentity, customer); if (int.TryParse(result, out int id)) { if (int.TryParse(result, out int receiverId)) { return(Ok(new { Message = "Save.Success", CustomerId = id, ReceiverId = receiverId })); } return(Ok(new { Message = "Save.Success", CustomerId = id, ReceiverId = 0 })); } return(Ok(new { Message = result, CustomerId = -1, ReceiverId = 0 })); }
public HttpResponseMessage UpdateCustomer(HttpRequestMessage request, CustomerInfoViewModel CustomerInfoVM) { HttpResponseMessage response = null; if (!ModelState.IsValid) { response = request.CreateResponse(HttpStatusCode.BadRequest, ModelState); } else { bool checkData = customerInfoService.UpdateCustomer(CustomerInfoVM); response = request.CreateResponse(HttpStatusCode.OK, checkData); } return(response); }
public CustomerInfoViewModel GetCustomer(int id) { if (_context.Customers.Where(c => c.CustomerId == id).Count() == 0) { CustomerInfoViewModel model = new CustomerInfoViewModel(); model.SetVisible(false); return(model); } else { CustomerInfoViewModel model = new CustomerInfoViewModel(); model.SetCustomer(new GetCustomer(_context).ByCustomerId(id)); // InfoQuery model.SetAccounts(new GetAccounts(_context).OfCustomer(model.Customer)); return(model); } }
// GET: CustomerController/Edit/5 public ActionResult Edit(Guid id) { CustomerInfoViewModel customerToEdit = _logic.GetCustomerById(id); if (customerToEdit == null) { ModelState.AddModelError("Failure", "Customer does not exist to edit"); return(View(customerToEdit)); } List <string> storeNames = _logic.GetStoreNames(); ViewBag.StoreNames = new SelectList(storeNames); return(View(customerToEdit)); }
public CustomerViewModel() { Customer = new Customer("Blackhat"); _childViewModel = new CustomerInfoViewModel(); UpdateCommand = new CustomerUpdateCommand(this); }