예제 #1
0
        public IActionResult Save(BranchIndexViewModel model)
        {
            var UserId = HttpContext.Session.GetString("UserId");

            if (ModelState.IsValid)
            {
                var branch = new Branch
                {
                    Id          = model.Id,
                    Description = model.Description,
                    Company     = _Branch.GetCompanyById(int.Parse(model.CompanyId))
                };
                if (model.Id.ToString().Equals("0"))
                {
                    branch.CreatedBy    = UserId;
                    branch.CreationDate = DateTime.Now;
                    _Branch.Add(branch);
                }
                else
                {
                    branch.ModifiedBy   = UserId;
                    branch.ModifiedDate = DateTime.Now;
                    _Branch.Update(branch);
                }
                return(RedirectToAction("Index"));
            }
            else
            {
                return(RedirectToAction("Index", model));
            }
        }
예제 #2
0
 public IActionResult Save(BranchViewModel model)
 {
     if (ModelState.IsValid)
     {
         var branch = new Branch
         {
             Id          = model.Id,
             Description = model.Description,
             Company     = _Branch.GetCompanyById(int.Parse(model.CompanyId))
         };
         if (model.Id.ToString().Length <= 0)
         {
             _Branch.Add(branch);
         }
         else
         {
             _Branch.Update(branch);
         }
     }
     return(View());
 }