Exemplo n.º 1
0
 public static long Save(VendorSiteModel model)
 {
     VendorSite entity = GetEntityByModel(model);
     return model.Id > 0
         ? service.Update(entity)
         : service.Insert(entity);
 }
        public ActionResult CreateSite(long id)
        {
            ViewBag.VendorName = VendorHelper.GetSingle(id.ToString()).Name;

            VendorSiteModel model = new VendorSiteModel(id);
            model.CodeCombination = codeCombinationService.GetAllCodeCombinitionView(AuthenticationHelper.CompanyId.Value)
                    .Select(x => new SelectListItem
                    {
                        Text = x.CodeCombinitionCode,
                        Value = x.Id.ToString()
                    }).ToList();
            //model.TaxCode = taxService.GetAll(AuthenticationHelper.CompanyId.value)
            //    .Select(x => new SelectListItem
            //    {
            //        Text = x.TaxName,
            //        Value = x.Id.ToString()
            //    }).ToList();
            return View(model);
        }
Exemplo n.º 3
0
 private static VendorSite GetEntityByModel(VendorSiteModel model)
 {
     if (model == null) return null;
     VendorSite entity = new VendorSite();
     entity.Id = model.Id;
     entity.Name = model.Name;
     entity.Address = model.Address;
     entity.CodeCombinationId = model.CodeCombinationId;
     entity.Contact = model.Contact;
     if (model.Id == 0)
     {
         entity.CreateBy = AuthenticationHelper.UserId;
         entity.CreateDate = DateTime.Now;
     }
     else
     {
         entity.CreateBy = model.CreateBy;
         entity.CreateDate = model.CreateDate;
     }
     entity.EndDate = model.EndDate;
     entity.StartDate = model.StartDate;
     entity.UpdateBy = AuthenticationHelper.UserId;
     entity.UpdateDate = DateTime.Now;
     entity.VendorId = model.VendorId;
     return entity;
 }
 public ActionResult CreateSite(VendorSiteModel model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             VendorModel vendor = VendorHelper.GetSingle(model.VendorId.ToString());
             if ((model.StartDate >= vendor.StartDate && model.EndDate <= vendor.EndDate) ||
                 (model.StartDate == null && vendor.StartDate == null ||
                 model.EndDate == null && vendor.EndDate == null))
             {
                 VendorHelper.Save(model);
                 return RedirectToAction("ListSites", new { Id = model.VendorId });
             }
             else
             {
                 ModelState.AddModelError("Error", "Site Dates must be within the range of Vendor Dates.");
             }
         }
         catch (Exception ex)
         {
             ModelState.AddModelError("Error", ex.Message);
         }
         //VendorHelper.Save(model);
         //return RedirectToAction("ListSites", new { Id = model.VendorId });
     }
     return View(model);
 }