Ejemplo n.º 1
0
 public void Update(Customer cust)
 {
     Customer exist = CustomerRepository.GetById(cust.id);
     if (exist.Email != cust.Email)
         FailIfExistEmail(cust);
     if(exist.KTPNo != cust.KTPNo)
         FailIfExistKTPNo(cust);
     Customer custUpdated = new Customer
     {
         id = exist.id,
         BranchId = exist.BranchId,
         Address = cust.Address,
         City = cust.City,
         Email = cust.Email,
         Name = cust.Name,
         Outstanding = exist.Outstanding,
         Phone = cust.Phone,
         Status = exist.Status,
         Region = cust.Region,
         KTPNo = cust.KTPNo,
         KTPDate = cust.KTPDate,
         KTPPublisher = cust.KTPPublisher,
         Job = cust.Job,
         Gender = cust.Gender,
         Birthday = cust.Birthday
     };
     ReportingRepository.Update<Customer>(custUpdated, new { id = custUpdated.id });
 }
Ejemplo n.º 2
0
 public JsonResult Customer(Customer cust)
 {
     try
     {
         CompanyProfile cp = new CompanyProfile(this.HttpContext);
         cust.id = Guid.NewGuid();
         cust.BranchId = cp.BranchId;
         CustomerService.Create(cust);
         return Json(new { error = false, data = cust }, JsonRequestBehavior.AllowGet);
     }
     catch (Exception ex)
     {
         return Json(new { error = true, message = ex.Message }, JsonRequestBehavior.AllowGet);
     }
 }
Ejemplo n.º 3
0
 public JsonResult UpdateCustomer(Customer cust)
 {
     try
     {
         CompanyProfile cp = new CompanyProfile(this.HttpContext);
         CustomerService.Update(cust);
         return Json(new { error = false, data = cust }, JsonRequestBehavior.AllowGet);
     }
     catch (Exception ex)
     {
         return Json(new { error = true, message = ex.Message }, JsonRequestBehavior.AllowGet);
     }
 }
Ejemplo n.º 4
0
 private void FailIfExistKTPNo(Customer cust)
 {
     if (CustomerRepository.GetByKTPNo(cust.KTPNo, cust.BranchId) != null)
         throw new Exception(string.Format("Pelanggan dengan Nomor KTP {0} telah terdaftar di perusahaan anda", cust.KTPNo));
 }
Ejemplo n.º 5
0
 private void FailIfExistEmail(Customer cust)
 {
     if (cust.Email != null && CustomerRepository.GetByEmail(cust.Email, cust.BranchId) != null)
         throw new Exception(string.Format("Email {0} telah terdaftar di perusahaan anda", cust.Email));
 }
Ejemplo n.º 6
0
 public void Create(Customer cust)
 {
     FailIfExistEmail(cust);
     FailIfExistKTPNo(cust);
     ReportingRepository.Save<Customer>(cust);
 }
Ejemplo n.º 7
0
 private Customer SaveCustomer(Customer cust)
 {
     Customer c = CustomerRepository.GetByKTPNo(cust.KTPNo, cust.BranchId);
     if (c == null)
     {
         CustomerService.Create(cust);
         return cust;
     }
     return c;
 }