Ejemplo n.º 1
0
        private static Customer getEntityByModel(CustomerModel model)
        {
            if (model == null) return null;

            Customer entity = new Customer();
            if (model.Id == 0)
            {
                entity.CreateBy = AuthenticationHelper.UserId;
                entity.CreateDate = DateTime.Now;
                entity.CompanyId = AuthenticationHelper.CompanyId.Value;
            }
            else
            {
                entity.CreateBy = model.CreateBy;
                entity.CreateDate = model.CreateDate;
                entity.CompanyId = model.CompanyId;
            }

            entity.Address = model.Address;
            entity.ContactNo = model.ContactNo;
            entity.CustomerName = model.CustomerName;
            entity.EndDate = model.EndDate;
            entity.Id = model.Id;
            entity.SOBId = SessionHelper.SOBId;
            entity.StartDate = model.StartDate;
            entity.UpdateBy = AuthenticationHelper.UserId;
            entity.UpdateDate = DateTime.Now;

            return entity;

        }
Ejemplo n.º 2
0
 public static string SaveCustomer(CustomerModel model)
 {
     if (model.Id > 0)
     {
         return service.Update(getEntityByModel(model));
     }
     else
     {
         return service.Insert(getEntityByModel(model));
     }
 }
 public ActionResult Edit(CustomerModel model)
 {
     if (ModelState.IsValid)
     {
         if (model.StartDate != null && model.StartDate > model.EndDate)
         {
             ModelState.AddModelError("Error", "Start Date cannot be greater than End Date.");
         }
         else
         {
             string result = CustomerHelper.SaveCustomer(model);
             return RedirectToAction("Index");
         }
         
     }
     return View(model);
 }