public CustomerDetail GetCustomerById(int id) { var entity = _context.Customers.Find(id); if (entity == null) { return(null); } List <PetListItem> petList = new List <PetListItem>(); foreach (var pet in entity.Pets) { petList.Add(new PetListItem { Name = $"{pet.Name}, " }); } List <AppointmentListItem> appList = new List <AppointmentListItem>(); List <AppointmentListItem> appListSorted = new List <AppointmentListItem>(); foreach (var app in entity.Appointments) { appList.Add(new AppointmentListItem { AppointmentDate = app.AppointmentDate, StartTime = app.StartTime, PetID = app.PetID, PetName = app.Pet.Name, }); } appListSorted = appList.OrderByDescending(x => x.AppointmentDate).ToList(); var model = new CustomerDetail { PersonID = entity.PersonID, FirstName = entity.FirstName, LastName = entity.LastName, StreetAddress = entity.StreetAddress, City = entity.City, State = entity.State, ZipCode = entity.ZipCode, PhoneNumber = entity.PhoneNumber, Email = entity.Email, Pets = petList, Appointments = appListSorted, }; return(model); }
public void CreateCustomerDetailsWithDifferentTags_CloseEachGroup() { CurrentCustomerProvider.Current.CurrentCustomerOid = Alex.Oid; using (CustomersList list = (CustomersList)ModulesManager.Current.OpenModuleObjectDetail(new CustomersListObject(Session), false)) { using (CurrentCustomerRentsDetail detail = (CurrentCustomerRentsDetail)ModulesManager.Current.OpenModuleObjectDetail(new CurrentCustomerRentsDetailObject(Session), false)) { list.ListEdit.CurrentRecord = Anton; list.CommandEdit("Anton"); CustomerDetail currentCustomerDetail = (CustomerDetail)detail.OpenDetail(Alex.Oid, "Alex"); list.CommandCloseDetails(null); Assert.AreNotEqual(0, ModulesManager.Current.GetModulesForType(currentCustomerDetail.GetModuleTypeKey()).Count); } } }
public IHttpActionResult GetcustomerByCustomer(CustomerDetail customerDetail) { try { var result = _phaniResumeBussinessLayer.SaveResumeDetails(customerDetail); return(Ok(result)); } catch (Exception e) { Console.WriteLine(e); return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e.Message))); } }
public ActionResult Save(CustomerDetail objCustomerInfo) { objCustomerInfo.CountryId = Convert.ToInt16(Request.Form["CountryId"]); if (ModelState.IsValid) { CustomerDetailBLL objCustomerBLL = new CustomerDetailBLL(); objCustomerBLL.SaveCustomerInfo(objCustomerInfo); } return(RedirectToAction("Index", "CustomerDetail")); }
public List <CustomerDetail> GetAllCustomerDetail(int userId) { try { if (this.cache.GetString(cacheKey) != null) { var data = JsonConvert.DeserializeObject <List <CustomerDetail> >(this.cache.GetString(cacheKey)); return(data); } else { using (this.connection) { SqlCommand command = new SqlCommand("spGetAllCustomerDetail", this.connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@UserId", userId); List <CustomerDetail> details = new List <CustomerDetail>(); CustomerDetail detail = new CustomerDetail(); this.connection.Open(); SqlDataReader dataReader = command.ExecuteReader(); while (dataReader.Read()) { if (dataReader != null) { detail.CustomerId = (int)dataReader["CustomerId"]; detail.UserId = (int)dataReader["UserId"]; detail.CustomerDetailTypeId = (int)dataReader["CustomerDetailTypeId"]; detail.Name = dataReader["Name"].ToString(); detail.PhoneNumber = dataReader["PhoneNumber"].ToString(); detail.Pincode = dataReader["Pincode"].ToString(); detail.Locality = dataReader["Locality"].ToString(); detail.Address = dataReader["Address"].ToString(); detail.City = dataReader["City"].ToString(); detail.Landmark = dataReader["Landmark"].ToString(); details.Add(detail); break; } } if (details != null) { this.cache.SetString(this.cacheKey, JsonConvert.SerializeObject(details)); } return(details); } } } catch (Exception e) { throw new Exception(e.Message); } }
public void CreateCustomer_CheckAllowSetAsCurrent() { using (CustomersList list = (CustomersList)ModulesManager.Current.OpenModuleObjectDetail(new CustomersListObject(Session), false)) { using (CustomerDetail detail = (CustomerDetail)list.OpenDetail(null, null)) { detail.CustomerEdit.VRObjectEditObject.VideoRentObject.FirstName = "x"; detail.CustomerEdit.VRObjectEditObject.VideoRentObject.LastName = "y"; Assert.IsFalse(detail.AllowSetAsCurrentCustomer); Assert.IsFalse(detail.SetAsCurrentCustomer()); Assert.IsTrue(detail.Save()); Assert.IsTrue(detail.AllowSetAsCurrentCustomer); Assert.IsTrue(detail.SetAsCurrentCustomer()); } } }
public ActionResult TgtVsAch(string CustomerId, string CustomerType) { TgtVsAchViewModel objData = new TgtVsAchViewModel(); try { var objCust = CDR.GetCustomerDetail(CustomerId, CustomerType); objCust.CustomerCategory = "Participant"; Session["ChitaleUser"] = objCust; CustomerDetail UserSession = new CustomerDetail(); UserSession = (CustomerDetail)Session["ChitaleUser"]; objData.objOverAll = PLR.GetOverallData(UserSession.CustomerId, "", ""); objData.objCategory = PLR.GetCategoryData(UserSession.CustomerId, "", ""); objData.objSubCategory = PLR.GetSubCategoryData(UserSession.CustomerId, "", ""); objData.objProducts = PLR.GetProductData(UserSession.CustomerId, "", ""); string[] names = DateTimeFormatInfo.CurrentInfo.MonthNames; List <SelectListItem> MonthItems = new List <SelectListItem>(); int Month = 1; foreach (var item in names) { MonthItems.Add(new SelectListItem { Text = Convert.ToString(item), Value = Convert.ToString(Month) }); Month++; } MonthItems.RemoveAt(12); objData.MonthItems = MonthItems; List <SelectListItem> YearItems = new List <SelectListItem>(); for (int i = 0; i <= 10; i++) { int year = DateTime.Now.Year; YearItems.Add(new SelectListItem { Text = Convert.ToString(year - i), Value = Convert.ToString(year - i) }); } objData.YearItems = YearItems; } catch (Exception ex) { newexception.AddException(ex); } return(View(objData)); }
// GET: CustomerDetails/Delete/5 public ActionResult Delete(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CustomerDetail customerDetail = db.CustomerDetails.Find(id); if (customerDetail == null) { return(HttpNotFound()); } return(View(customerDetail)); }
public IHttpActionResult DeleteCustomerDetail(int id) { CustomerDetail customerDetail = db.CustomerDetails.Find(id); if (customerDetail == null) { return(NotFound()); } db.CustomerDetails.Remove(customerDetail); db.SaveChanges(); return(Ok(customerDetail)); }
public async Task <ActionResult <CustomerID> > PostCustomerDetail(CustomerDetail customerDetail) { /* * will need to do some validation here * are they over 18? * is there an email or a DOB (need at least one) * */ Boolean bln = false; if (customerDetail.Email is null && customerDetail.DOB is null) { return(ValidationProblem()); }
public async Task <EntityApiResponse <CustomerDetail> > CreateCustomerAsync(CustomerDetail customerDetail, string currentUserId) { if (customerDetail is null) { throw new ArgumentNullException(nameof(customerDetail)); } var org = await _orgRepository.GetByIdAsync(customerDetail.OrganizationId); if (org is null) { return(new EntityApiResponse <CustomerDetail>(error: "Organization does not exist")); } var country = await _countryRepository.GetByIdAsync(customerDetail.Country?.Id); if (country is null) { return(new EntityApiResponse <CustomerDetail>(error: "Country does not exist")); } var customerWithSameInfo = await _customerRepository.TableNoTracking .FirstOrDefaultAsync(c => c.FirstName == customerDetail.FirstName && c.LastName == customerDetail.LastName); if (!(customerWithSameInfo is null)) { return(new EntityApiResponse <CustomerDetail>(error: "A customer already exist with the same name")); } var customer = new Customer { FirstName = customerDetail.FirstName?.Trim(), LastName = customerDetail.LastName?.Trim(), Email = customerDetail.Email?.Trim(), Phone = customerDetail.Phone?.Trim(), Address = customerDetail.Address?.Trim(), StreetAddress = customerDetail.StreetAddress?.Trim(), City = customerDetail.City?.Trim(), Barcode = customerDetail.Barcode?.Trim(), CountryId = country.Id, CreatedById = currentUserId, ModifiedById = currentUserId, OrganizationId = org.Id }; await _customerRepository.InsertAsync(customer); return(new EntityApiResponse <CustomerDetail>(entity: new CustomerDetail(customer))); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } CustomerDetail = await _context.CustomerDetail.FirstOrDefaultAsync(m => m.Customer_ID == id); if (CustomerDetail == null) { return(NotFound()); } return(Page()); }
// GET: CustomerDetails/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CustomerDetail customerDetail = db.CustomerDetails.Find(id); if (customerDetail == null) { return(HttpNotFound()); } ViewBag.BusinessCatageoryId = new SelectList(db.BusinessCatageories, "Id", "Name", customerDetail.BusinessCatageoryId); return(View(customerDetail)); }
// GET: Customer/Details/5 public async Task <ActionResult> Details(Guid id) { var c = new CustomerDetail(); var apiClient = await HttpContext.CreateHttpAsync(); var responseMessage = await apiClient.GetAsync(_configuration.CrmGetContact(id)); if (responseMessage.IsSuccessStatusCode) { var values = responseMessage.Content.ReadAsStringAsync(); c = JsonConvert.DeserializeObject <CustomerDetail>(values.Result); } return(View(c)); }
public object UpdateCustomer(CustomerDetail objCustomerDetail) { try { SqlConnection con = new SqlConnection("Data Source=DESKTOP-SS8I9A6;Initial Catalog=happy;Integrated Security=True"); SqlCommand cmd = new SqlCommand("spUpdateCustomer", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@CustomerID", objCustomerDetail.CustomerID); cmd.Parameters.AddWithValue("@Name", objCustomerDetail.Name); cmd.Parameters.AddWithValue("@Email", objCustomerDetail.Email); cmd.Parameters.AddWithValue("@Address", objCustomerDetail.Address); cmd.Parameters.AddWithValue("@ContactNo", objCustomerDetail.ContactNo); cmd.Parameters.AddWithValue("@city", objCustomerDetail.city); //cmd.Parameters.AddWithValue("@Enabled", objCustomerDetail.Enabled); cmd.Parameters.AddWithValue("@DOB", objCustomerDetail.DOB); cmd.Parameters.AddWithValue("@Street", objCustomerDetail.Street); cmd.Parameters.AddWithValue("@State", objCustomerDetail.State); cmd.Parameters.AddWithValue("@PIN", objCustomerDetail.PIN); cmd.Parameters.AddWithValue("@ParentID", objCustomerDetail.ParentID); con.Open(); int k = cmd.ExecuteNonQuery(); if (k != 0) { return("sucess"); } else { return("Fail"); } return(new Response { Status = "Success", Message = "SuccessFully Saved." }); } catch (Exception Ex) { return(new Response { Status = "Error", Message = "Invalid Data." }); } }
public async Task Register(string userInfoJSON) { // 1) Deserialize user JSON // 2) Check if user already exist // 3) Hash password (Stuff from Web API project can be reused) // 4) Add customer/user to DB // 5) Return token CustomerDetail newCustomer = new CustomerDetail() { }; }
public ActionResult Edit(CustomerDetail mdl) { CustomerDetail usr = new CustomerDetail(); usr.CustomerId = mdl.CustomerId; usr.CustorName = mdl.CustorName; usr.Address = mdl.Address; int Retval = ur.UpdateCustomer(usr.CustomerId, usr.CustorName, usr.Address); if (Retval > 0) { return(RedirectToAction("Index", "Home")); } return(View()); }
public CustomerController() { db = new FMSEntities(); Contacts = new List <CustomerDetail>(); for (int i = 0; i < 100; i++) { var c = new CustomerDetail(); c.customerId = "first name" + i; c.Name = "last name" + i; c.Phone = "other name" + i; c.Resident = "phone number" + i; c.IsActive = true; Contacts.Add(c); } }
// GET: Home public ActionResult Index() { List <CustomerDetail> lstRecord = new List <CustomerDetail>(); var lst = ur.GetAllCustomers(); foreach (var item in lst) { CustomerDetail usr = new CustomerDetail(); usr.CustomerId = item.CustomerId; usr.CustorName = item.CustorName; usr.Address = item.Address; lstRecord.Add(usr); } return(View(lstRecord)); }
public object NewTransaction(Transact tr) { try { Transaction_Detail td = new Transaction_Detail(); CustomerDetail cr = new CustomerDetail(); if (td.TransactionId == 0) { td.Time = tr.Time; td.Remarks = tr.Remarks; td.Mode = tr.Mode; td.Amount = tr.Amount; td.CustomerId = tr.CustomerId; var bal = DB1.CustomerDetails.Where(x => x.CustomerId == tr.CustomerId).ToList().FirstOrDefault(); if (bal.OpeningBal >= td.Amount && td.Mode == "Debit") { DB.Transaction_Detail.Add(td); DB.SaveChanges(); return new Response { Status = "Success", Message = "Transaction Successfull" }; } else if (td.Mode == "Credit") { DB.Transaction_Detail.Add(td); DB.SaveChanges(); return new Response { Status = "Success", Message = "Transaction Successfull" }; } else { return new Response { Status = "Error", Message = "Invalid Data." }; } } } catch (Exception) { throw; } return new Response { Status = "Error", Message = "Invalid Data." }; }
/// <summary> /// Maps a CustomerDetail data model to a CustomerDetailModel view model /// </summary> /// <param name="detail"></param> /// <returns></returns> /// public static CustomerDetailModel MapCustomerDetail(CustomerDetail detail) { return(new CustomerDetailModel { Id = detail.Id, Email = detail.Email, Phone = detail.Phone, PrimaryAddress = detail.PrimaryAddress, AlternateAddress = detail.AlternateAddress, City = detail.City, State = detail.State, PostalCode = detail.PostalCode, Country = detail.Country, CreatedAt = DateTime.UtcNow, UpdatedAt = DateTime.UtcNow, }); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } CustomerDetail = await _context.CustomerDetail.FindAsync(id); if (CustomerDetail != null) { _context.CustomerDetail.Remove(CustomerDetail); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <EntityApiResponse <CustomerDetail> > UpdateCustomerAsync(CustomerDetail customerDetail, string currentUserId) { if (customerDetail is null) { throw new ArgumentNullException(nameof(customerDetail)); } var customer = await _customerRepository.GetByIdAsync(customerDetail.Id); if (customer is null) { return(new EntityApiResponse <CustomerDetail>(error: "Customer does not exist")); } var country = await _countryRepository.GetByIdAsync(customerDetail.Country?.Id); if (country is null) { return(new EntityApiResponse <CustomerDetail>(error: "Country does not exist")); } var customerWithSameInfo = await _customerRepository.TableNoTracking .FirstOrDefaultAsync(c => c.FirstName == customerDetail.FirstName && c.LastName == customerDetail.LastName && c.Id != customerDetail.Id); if (!(customerWithSameInfo is null)) { return(new EntityApiResponse <CustomerDetail>(error: "A customer already exist with the same name")); } customer.FirstName = customerDetail.FirstName?.Trim(); customer.LastName = customerDetail.LastName?.Trim(); customer.Email = customerDetail.Email?.Trim(); customer.Phone = customerDetail.Phone?.Trim(); customer.Address = customerDetail.Address?.Trim(); customer.StreetAddress = customerDetail.StreetAddress?.Trim(); customer.City = customerDetail.City?.Trim(); customer.Barcode = customerDetail.Barcode?.Trim(); customer.CountryId = country.Id; customer.LastModifiedDate = DateTime.UtcNow; customer.ModifiedById = currentUserId; await _customerRepository.UpdateAsync(customer); return(new EntityApiResponse <CustomerDetail>(entity: new CustomerDetail(customer))); }
private void PopulateModel(CustomerDetail model, IDictionary values) { string ID = nameof(CustomerDetail.id); string FIRST_NAME = nameof(CustomerDetail.first_name); string LAST_NAME = nameof(CustomerDetail.last_name); string EMAIL = nameof(CustomerDetail.email); string CONTACT = nameof(CustomerDetail.contact); string CREATED_AT = nameof(CustomerDetail.created_at); string UPDATED_AT = nameof(CustomerDetail.updated_at); if (values.Contains(ID)) { model.id = Convert.ToInt32(values[ID]); } if (values.Contains(FIRST_NAME)) { model.first_name = Convert.ToString(values[FIRST_NAME]); } if (values.Contains(LAST_NAME)) { model.last_name = Convert.ToString(values[LAST_NAME]); } if (values.Contains(EMAIL)) { model.email = Convert.ToString(values[EMAIL]); } if (values.Contains(CONTACT)) { model.contact = Convert.ToDecimal(values[CONTACT]); } if (values.Contains(CREATED_AT)) { model.created_at = Convert.ToDateTime(values[CREATED_AT]); } if (values.Contains(UPDATED_AT)) { model.updated_at = Convert.ToDateTime(values[UPDATED_AT]); } }
public ActionResult SubmitPoints(string mobileNo, string ranking, string GroupId, string SalesRepresentative, string Comments, string outletId) { string status = "false"; CustomerDetail objcustomerdetails = new CustomerDetail(); try { status = FMR.SubmitRating(mobileNo, ranking, GroupId, SalesRepresentative, Comments, outletId); } catch (Exception ex) { newexception.AddException(ex, "submit rating"); } return(new JsonResult() { Data = status, JsonRequestBehavior = JsonRequestBehavior.AllowGet, MaxJsonLength = Int32.MaxValue }); }
public IActionResult UpdateCustomerDetail(CustomerDetail detail) { try { var userId = TokenUserId(); detail.UserId = userId; var result = this.customerDetailManager.UpdateCustomerDetail(detail); if (result != null) { return(this.Ok(new { Status = true, Message = "Customer Detail Updated Successfully", Data = result })); } return(this.BadRequest(new { Status = true, Message = "Unable to Update Customer detail" })); } catch (Exception e) { return(this.BadRequest(new { Status = false, Message = e.Message })); } }
public CustomerDetail GetCustomerByMobileNo(string GroupId, string MobileNo) { CustomerDetail objCustomerDetail = new CustomerDetail(); try { string connStr = objCustRepo.GetCustomerConnString(GroupId); using (var contextNew = new BOTSDBContext(connStr)) { objCustomerDetail = contextNew.CustomerDetails.Where(x => x.MobileNo == MobileNo).FirstOrDefault(); } } catch (Exception ex) { newexception.AddException(ex, GroupId); } return(objCustomerDetail); }
public void TestFailing_AddCustomerDetail() { using (var context = new CustomerDetailsContext(DBOptions)) { var failingCustomerDatail = new CustomerDetail() { CreditCard = "12p45678", CVC = "123", ExpiryDate = new DateTime(2022, 11, 11), Name = "Tester" }; CustomerDetailDAO _dao = new CustomerDetailDAO(context); Assert.Throws(typeof(Exception), () => { _dao.AddCustomerDetail(failingCustomerDatail); }); } }
public ActionResult SubmitotherinfowithPoints(string MemberName, string Gender, string BirthDt, string mobileNo, string AnniversaryDt, string Knowabt, string GroupId, string OutletId) { bool status = false; CustomerDetail objcustomerdetails = new CustomerDetail(); try { status = FMR.Submitotherinfo(MemberName, Gender, BirthDt, mobileNo, AnniversaryDt, Knowabt, GroupId, OutletId); } catch (Exception ex) { newexception.AddException(ex, "submit points"); } return(new JsonResult() { Data = status, JsonRequestBehavior = JsonRequestBehavior.AllowGet, MaxJsonLength = Int32.MaxValue }); }
public ActionResult Index(CustomerDetail objUser) { if (ModelState.IsValid) { using (starmedsdbEntities db = new starmedsdbEntities()) { var obj = db.Admins.Where(a => a.AdminUserName.Equals(objUser.UserName) && a.Password.Equals(objUser.Password)).FirstOrDefault(); if (obj != null) { Session["AdminId"] = obj.AdminId.ToString(); Session["AdminUserName"] = obj.AdminUserName.ToString(); Session["AdminName"] = obj.AdminName.ToString(); return(RedirectToAction("Index", "DashBoard")); } } } return(View(objUser)); }