public void ServiceReturnsSameIdAsRequested() { // Arrange var config = new MapperConfiguration(cfg => { //Create all maps here cfg.CreateMap <Customer, CustomerServiceModel>(); cfg.CreateMap <Transaction, TransactionServiceModel>(); }); var mapper = config.CreateMapper(); var mockRepository = new Mock <ICustomerRepository>(); mockRepository.Setup(x => x.GetCustomerBy(1)).Returns(new Data.Customer { ID = 1 }); var service = new CustomerService.Data.Services.Impl.CustomerService(mockRepository.Object, mapper); // Act CustomerServiceModel actionResult = service.GetCustomer(new Data.Services.ServiceModels.ServiceRequestModels.CustomerServiceRequestModel() { customerID = 1 }); // Assert Assert.AreEqual(1, actionResult.ID); }
public ActionResult Home() { try { if (TempData["errorMsg"] != null) { ViewBag.errorMsg = TempData["errorMsg"]; TempData["errorMsg"] = null; } CustomerServiceModel servicesModel = GetServices(1); if (servicesModel.Services == null) { TempData["errorMsg"] = LangText.checkConnection; return(RedirectToAction("login", "Login")); } else if (servicesModel.Services.Count == 0) { return(View(servicesModel)); } else if (servicesModel.Services.FirstOrDefault().id == 0) { TempData["errorMsg"] = LangText.somethingWentWrongAlert; return(RedirectToAction("login", "Login")); } else { return(View(servicesModel)); } } catch (Exception ex) { ExceptionsWriter.saveEventsAndExceptions(ex, "Exceptions not handled", EventLogEntryType.Error); return(View("Error")); } }
public IActionResult CustomerServiseMessage() { var model = new CustomerServiceModel(); if ((_workContext.CurrentCustomer.IsRegistered())) { var user = _workContext.CurrentCustomer; model = new CustomerServiceModel { IsLoggedIn = true, Phone = user.Mobile, Email = user.Email, FullName = user.GetFullName(), UserId = user.Id }; } else { model = new CustomerServiceModel { IsLoggedIn = false }; } return(View("~/Themes/Pavilion/Views/Harag/Post/AddCustomerServiceMessage.cshtml", model)); }
public ActionResult Add(long?id) { var service = _iCustomerService; Entities.CustomerServiceInfo customerServiceInfo; if (id.HasValue && id > 0) { customerServiceInfo = service.GetCustomerService(CurrentSellerManager.ShopId, id.Value); } else { customerServiceInfo = new Entities.CustomerServiceInfo(); } var customerServiceModels = new CustomerServiceModel() { Id = customerServiceInfo.Id, Account = customerServiceInfo.AccountCode, Name = customerServiceInfo.Name, Tool = customerServiceInfo.Tool, Type = customerServiceInfo.Type }; return(View(customerServiceModels)); }
public async Task <Outcome <int> > Register(CustomerServiceModel customerServiceModel) { CustomerEntity customer = _mapper.Map <CustomerEntity>(customerServiceModel); bool IsCustomerExist = await _customerRepository.IsPolicyAlreadyRegistered(customer); if (IsCustomerExist) { return(new Outcome <int>( "Policy has already registered, please check the policy reference number", System.Net.HttpStatusCode.BadRequest, 0)); } var savedEntity = await _customerRepository.AddAsync(customer); if (savedEntity?.CustomerId != 0) { return(new Outcome <int>( "Customer registered sucessfully", System.Net.HttpStatusCode.OK, savedEntity.CustomerId)); } else { return(new Outcome <int>( "Please try again, Request has not processed", System.Net.HttpStatusCode.ServiceUnavailable, 0)); } }
public JsonResult Add(CustomerServiceModel customerServiceModel) { var service = _iCustomerService; Entities.CustomerServiceInfo customerServiceInfo = new Entities.CustomerServiceInfo() { Id = customerServiceModel.Id, Type = customerServiceModel.Type.GetValueOrDefault(Entities.CustomerServiceInfo.ServiceType.PreSale), Tool = customerServiceModel.Tool, Name = customerServiceModel.Name, AccountCode = customerServiceModel.Account, ShopId = CurrentSellerManager.ShopId, TerminalType = Mall.Entities.CustomerServiceInfo.ServiceTerminalType.PC, ServerStatus = Mall.Entities.CustomerServiceInfo.ServiceStatusType.Open }; if (customerServiceInfo.Id > 0) { service.UpdateCustomerService(customerServiceInfo); } else { service.AddCustomerService(customerServiceInfo); } return(Json(new { success = true })); }
public JsonResult SaveDetails(CustomerListViewModel customer) { CustomerServiceModel CustomerModel; CustomerModel = new CustomerServiceModel() { Id = customer.Id, Address1 = customer.Address1, Address2 = customer.Address2, AddedDate = customer.AddedDate, CompanyId = customer.CompanyId, CustomerCode = customer.CustomerCode, FirstName = customer.FirstName, LastName = customer.LastName, OfficeName = customer.OfficeName, Email = customer.Email, Lat = customer.Lat, Lng = customer.Lng, Phone1 = customer.Phone1, Phone2 = customer.Phone2, Website = customer.Website, ZipCode = customer.ZipCode }; _ICustomerService.SaveCustomerDetails(CustomerModel); bool success = true; return(Json(success, JsonRequestBehavior.AllowGet)); }
/// <summary> /// Update Customer information in DB /// </summary> /// <param name="customer"></param> /// <returns>result status</returns> public async Task <bool> UpdateAsync(CustomerServiceModel customer) { var oldCustomer = await this.GetCustomerFromDBAsync(customer.Id); var updatedCusromer = customer.UpdateProperties(oldCustomer); // TODO 500 return(await customerRepository.UpdateAsync(updatedCusromer)); }
/// <summary> /// Add new Customer to DB /// </summary> /// <param name="customer"></param> /// <returns>new Customer's id</returns> public async Task <Guid> SaveAsync(CustomerServiceModel customer) { var repositoryCustomer = new Customer { FirstName = customer.FirstName, LastName = customer.LastName, Age = customer.Age }; return(await customerRepository.InsertAsync(repositoryCustomer)); }
private void button1_Click(object sender, EventArgs e) { CustomerServiceModel model = new CustomerServiceModel { TimeCreated = DateTime.Now.ToString(), TimeModified = DateTime.Now.ToString(), Name = txtName.Text, FullName = txtName.Text, IsActive = chkActive.Checked, CompanyName = txtCompanyName.Text, Salutation = txtSalutation.Text, FirstName = txtFirstName.Text, MiddleName = txtMiddleName.Text, LastName = txtLastName.Text, BillAddress = new BillAddressSVModel { Addr1 = txtBAddr1.Text, Addr2 = txtBAddr2.Text, Addr3 = txtBAddr3.Text, Addr4 = txtBAddr4.Text, City = txtBCity.Text, Country = txtBCountry.Text, PostalCode = txtBPostalCode.Text, State = txtBState.Text }, ShipAddress = new ShipAddressSVModel { Addr2 = txtSAddr2.Text, Addr3 = txtSAddr3.Text, Addr4 = txtSAddr4.Text, City = txtSCity.Text, PostalCode = txtSPostalCode.Text, State = txtSState.Text } /*Phone * AltPhone * Fax * Email * Contact * AltContact * Balance * TotalBalance * ResaleNumber * AccountNumber * CreditLimit * JobStatus * JobStartDate * JobProjectedEndDate * JobEndDate * JobDesc */ }; }
public void TestInitialize() { this.service = new CustomerService(new CustomerRepositoryStub()); var repositoryCustomer = TestCustomersCollection.TestCustomer; this.testCustomer = new CustomerServiceModel { Id = repositoryCustomer.Id, FirstName = repositoryCustomer.FirstName, LastName = repositoryCustomer.LastName, Age = repositoryCustomer.Age }; }
private CustomerServiceModel GetServices(int currentPage) { int maxRows = 8; BusinessAccessLayer.BALCommon.BALCommon bALCommon = new BusinessAccessLayer.BALCommon.BALCommon(); BusinessAccessLayer.BALService.BALService bALService = new BusinessAccessLayer.BALService.BALService(); List <BusinessObjects.Models.Service> lstServices = bALService.selectServicesByBankId(((BusinessObjects.Models.User)Session["UserObj"]).bankId); CustomerServiceModel servicesModel = new CustomerServiceModel(); servicesModel.Services = lstServices.ToList().Skip((currentPage - 1) * maxRows).Take(maxRows).ToList(); double pageCount = (double)((decimal)lstServices.Count() / Convert.ToDecimal(maxRows)); servicesModel.PageCount = (int)Math.Ceiling(pageCount); servicesModel.CurrentPageIndex = currentPage; return(servicesModel); }
/// <summary> /// Add new customer /// </summary> /// <param name="model"></param> /// <returns></returns> public ResponseModel AddCustomer(CustomerServiceModel model) { string inputxml = AppConstants.CustomerAdd.Replace("#NAME#", model.Name) .Replace("#ISACTIVE#", model.IsActive.ToString()) .Replace("#COMPANY#", model.CompanyName) .Replace("#Salutation#", model.Salutation) .Replace("#FirstName#", model.FirstName) .Replace("#MiddleName#", model.MiddleName) .Replace("#LastName#", model.LastName) .Replace("#BAddr1#", model.BillAddress.Addr1) .Replace("#BAddr2#", model.BillAddress.Addr2) .Replace("#BAddr3#", model.BillAddress.Addr3) .Replace("#BAddr4#", model.BillAddress.Addr4) .Replace("#BCity#", model.BillAddress.City) .Replace("#BState#", model.BillAddress.State) .Replace("#BPostalCode#", model.BillAddress.PostalCode) .Replace("#BCountry#", model.BillAddress.Country) .Replace("#SAddr1#", model.ShipAddress.Addr1) .Replace("#SAddr2#", model.ShipAddress.Addr2) .Replace("#SAddr3#", model.ShipAddress.Addr3) .Replace("#SAddr4#", model.ShipAddress.Addr4) .Replace("#SCity#", model.ShipAddress.City) .Replace("#SState#", model.ShipAddress.State) .Replace("#SPostalCode#", model.ShipAddress.PostalCode) .Replace("#SCountry#", model.ShipAddress.Country) .Replace("#Phone#", model.Phone) .Replace("#AltPhone#", model.AltPhone) .Replace("#Fax#", model.Fax) .Replace("#Email#", model.Email) .Replace("#Contact#", model.Contact) .Replace("#AltContact#", model.AltContact) .Replace("#OpenBalance#", model.TotalBalance) .Replace("#OpenBalanceDate#", "") .Replace("#ResaleNumber#", model.ResaleNumber) .Replace("#AccountNumber#", model.AccountNumber) .Replace("#CreditLimit#", model.CreditLimit) .Replace("#JobStatus#", model.JobStatus) .Replace("#JobStartDate#", model.JobStartDate) .Replace("#JobProjectedEndDate#", model.JobProjectedEndDate) .Replace("#JobEndDate#", model.JobEndDate) .Replace("#JobDesc#", model.JobDesc); return(new ResponseModel { Succeeded = true }); }
private CustomerServiceModel GetServices(int currentPage) { int maxRows = 7; BusinessAccessLayer.BALCommon.BALCommon bALCommon = new BusinessAccessLayer.BALCommon.BALCommon(); BusinessAccessLayer.BALService.BALService bALService = new BusinessAccessLayer.BALService.BALService(); ClaimsPrincipal principal = HttpContext.User as ClaimsPrincipal; var bankId = Convert.ToInt32(principal.FindFirst("BankId").Value); List <BusinessObjects.Models.Service> lstServices = bALService.selectServicesByBankId(bankId); CustomerServiceModel servicesModel = new CustomerServiceModel(); servicesModel.Services = lstServices.ToList().Skip((currentPage - 1) * maxRows).Take(maxRows).ToList(); double pageCount = (double)((decimal)lstServices.Count() / Convert.ToDecimal(maxRows)); servicesModel.PageCount = (int)Math.Ceiling(pageCount); servicesModel.CurrentPageIndex = currentPage; return(servicesModel); }
public IActionResult Edit(int id) { CustomerServiceModel customer = this.customerService.GetCustomerById(id); if (customer == null) { return(NotFound()); } CustomerFormModel model = new CustomerFormModel { Name = customer.Name, BirthDate = customer.BirthDate, IsYoungDriver = customer.IsYoungDriver }; return(View(model)); }
public ActionResult Add(long?id) { CustomerServiceInfo customerServiceInfo; CustomerServiceModel customerServiceModel; ICustomerService customerService = ServiceHelper.Create <ICustomerService>(); if (id.HasValue) { long?nullable = id; if ((nullable.GetValueOrDefault() <= 0 ? true : !nullable.HasValue)) { customerServiceInfo = new CustomerServiceInfo(); customerServiceModel = new CustomerServiceModel() { Id = customerServiceInfo.Id, Account = customerServiceInfo.AccountCode, Name = customerServiceInfo.Name, Tool = customerServiceInfo.Tool, Type = new CustomerServiceInfo.ServiceType?(customerServiceInfo.Type) }; return(View(customerServiceModel)); } customerServiceInfo = customerService.GetCustomerService(base.CurrentSellerManager.ShopId, id.Value); customerServiceModel = new CustomerServiceModel() { Id = customerServiceInfo.Id, Account = customerServiceInfo.AccountCode, Name = customerServiceInfo.Name, Tool = customerServiceInfo.Tool, Type = new CustomerServiceInfo.ServiceType?(customerServiceInfo.Type) }; return(View(customerServiceModel)); } customerServiceInfo = new CustomerServiceInfo(); customerServiceModel = new CustomerServiceModel() { Id = customerServiceInfo.Id, Account = customerServiceInfo.AccountCode, Name = customerServiceInfo.Name, Tool = customerServiceInfo.Tool, Type = new CustomerServiceInfo.ServiceType?(customerServiceInfo.Type) }; return(View(customerServiceModel)); }
public bool SendMail(string from, string to, CustomerServiceModel mailModel) { SmtpClient smtpClient = new SmtpClient(); smtpClient.Host = this.emailHost; smtpClient.Port = 25; smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network; smtpClient.Credentials = new System.Net.NetworkCredential(server, password); smtpClient.UseDefaultCredentials = false; MailMessage mailMessage = new MailMessage(from, to); mailMessage.Subject = mailModel.FullName + " | من عميل موقع المزارع"; mailMessage.Body = String.Format( "تفاصيل رساله العميل الي اداره موقع " + mailModel.ContactDepartment + " \n" + "الاسم : {0} {1} \n" + "الهاتف: {2} \n" + "القسم: {3} \n" + "نوع الاستفسار: {4} \n" + "البريد الالكتروني: {5} \n" + "محتوي الرساله: {6} \n", "", mailModel.FullName, mailModel.Phone, mailModel.ContactDepartment, mailModel.ContactType, mailModel.Email, mailModel.Message).ToString(); try { smtpClient.Send(mailMessage); } catch (Exception e) { return(false); } return(true); }
private void SetupModels() { _customerId = 1; _customerServiceModel = new CustomerServiceModel { Id = _customerId, Name = "pera", LastName = "Peric" }; _customerServiceModelInvalid = new CustomerServiceModel { Id = _customerId, Name = "pera" }; _customerControllerModelInvalid = new CustomerControllerModel { Id = _customerServiceModelInvalid.Id, Name = _customerServiceModelInvalid.Name }; _customerControllerModel = new CustomerControllerModel { Id = _customerServiceModel.Id, Name = _customerServiceModel.Name, LastName = _customerServiceModel.LastName }; _custumerSreviceModelList = new List <CustomerServiceModel> { new CustomerServiceModel { Id = 2, Name = "pera", LastName = "Peric" }, new CustomerServiceModel { Id = 3, Name = "pera", LastName = "Peric" } }; _custumerControllerModelList = new List <CustomerControllerModel> { new CustomerControllerModel { Id = 2, Name = "pera", LastName = "Peric" }, new CustomerControllerModel { Id = 3, Name = "pera", LastName = "Peric" } }; }
public ActionResult addMobile() { var service = _iCustomerService; Entities.CustomerServiceInfo customerServiceInfo; customerServiceInfo = service.GetCustomerServiceForMobile(CurrentSellerManager.ShopId); if (customerServiceInfo == null) { customerServiceInfo = new Entities.CustomerServiceInfo(); } var customerServiceModels = new CustomerServiceModel() { Id = customerServiceInfo.Id, Account = customerServiceInfo.AccountCode, Name = customerServiceInfo.Name, Tool = customerServiceInfo.Tool, Type = customerServiceInfo.Type }; return(View(customerServiceModels)); }
public ActionResult Home(int currentPageIndex) { CustomerServiceModel servicesModel = GetServices(currentPageIndex); if (servicesModel.Services == null) { TempData["errorMsg"] = LangText.checkConnection; return(RedirectToAction("login", "Login")); } else if (servicesModel.Services.Count == 0) { return(View(servicesModel)); } else if (servicesModel.Services.FirstOrDefault().id == 0) { TempData["errorMsg"] = LangText.somethingWentWrongAlert; return(RedirectToAction("login", "Login")); } else { return(View(servicesModel)); } }
public void SaveCustomerDetails(CustomerServiceModel CustomerDetails) { var customer = new CustomerModel() { Id = CustomerDetails.Id, Address1 = CustomerDetails.Address1, Address2 = CustomerDetails.Address2, AddedDate = CustomerDetails.AddedDate, CompanyId = CustomerDetails.CompanyId, CustomerCode = CustomerDetails.CustomerCode, FirstName = CustomerDetails.FirstName, LastName = CustomerDetails.LastName, OfficeName = CustomerDetails.OfficeName, Email = CustomerDetails.Email, Lat = CustomerDetails.Lat, Lng = CustomerDetails.Lng, Phone1 = CustomerDetails.Phone1, Phone2 = CustomerDetails.Phone2, Website = CustomerDetails.Website, ZipCode = CustomerDetails.ZipCode }; _ICustomerRepository.SaveCustomerDetails(customer); }
public JsonResult Add(CustomerServiceModel customerServiceModel) { ICustomerService customerService = ServiceHelper.Create <ICustomerService>(); CustomerServiceInfo customerServiceInfo = new CustomerServiceInfo() { Id = customerServiceModel.Id, Type = customerServiceModel.Type.GetValueOrDefault(CustomerServiceInfo.ServiceType.PreSale), Tool = customerServiceModel.Tool, Name = customerServiceModel.Name, AccountCode = customerServiceModel.Account, ShopId = base.CurrentSellerManager.ShopId }; CustomerServiceInfo customerServiceInfo1 = customerServiceInfo; if (customerServiceInfo1.Id <= 0) { customerService.AddCustomerService(customerServiceInfo1); } else { customerService.UpdateCustomerService(customerServiceInfo1); } return(Json(new { success = true })); }
public Task <Guid> SaveAsync(CustomerServiceModel entity) { return(Task.FromResult(new Guid())); }
public Task <bool> UpdateAsync(CustomerServiceModel entity) { return(Task.FromResult(true)); }
public IActionResult CustomerServiseMessage(CustomerServiceModel customerService) { var reCaptcha = Request.Form["g-recaptcha-response"]; if (string.IsNullOrEmpty(reCaptcha)) { ModelState.AddModelError("", "لم يتم التحقق اكمل اختبار الروبوت"); return(View("~/Themes/Pavilion/Views/Harag/Post/AddCustomerServiceMessage.cshtml", customerService)); } var r = reCaptcha.ToList(); if (_workContext.CurrentCustomer.IsRegistered()) { var message = new Z_Harag_CustomerServicesMessage { Message = customerService.Message, UserId = _workContext.CurrentCustomer.Id, Time = DateTime.Now }; var emeilaManager = new EmailManager(this.email, this.server, this.pass); var result = emeilaManager.SendMail(customerService.Email ?? "*****@*****.**", this.emails, customerService); if (result) { //_customerServiceContext.AddCustomerServiceMessage(message); return(View("~/Themes/Pavilion/Views/Harag/Post/CustomerServiceMessageAdded.cshtml")); } else { ModelState.AddModelError("", "لم يتم الارسال حاول مجددا "); return(View("~/Themes/Pavilion/Views/Harag/Post/AddCustomerServiceMessage.cshtml", customerService)); } } else { var message = new Z_Harag_CustomerServicesMessage { Message = customerService.Message, UserId = 0, Time = DateTime.Now }; var emeilaManager = new EmailManager(this.email, this.server, this.pass); var result = emeilaManager.SendMail(customerService.Email ?? "*****@*****.**", this.emails, customerService); if (result) { _customerServiceContext.AddCustomerServiceMessage(message); return(View("~/Themes/Pavilion/Views/Harag/Post/CustomerServiceMessageAdded.cshtml")); } else { ModelState.AddModelError("", "لم يتم الارسال حاول مجددا "); return(View("~/Themes/Pavilion/Views/Harag/Post/AddCustomerServiceMessage.cshtml", customerService)); } } return(View("~/Themes/Pavilion/Views/Harag/Post/AddCustomerServiceMessage.cshtml", customerService)); }