Exemple #1
0
 public ActionResult CreateOrUpdate(LabourServiceMapFormViewModel viewModel) // model binding
 {
     if (viewModel.LabourServiceMap.Id == 0)                                 // Create
     {
         labourServiceMapRepository.Insert(viewModel.LabourServiceMap);
         return(RedirectToAction("LabourServiceMapList", "LabourServiceMap"));
     }
     else // Update
     {
         var labourServiceMap = labourServiceMapRepository.Update(viewModel.LabourServiceMap);
         return(RedirectToAction("LabourServiceMapList", "LabourServiceMap"));
     }
 }
Exemple #2
0
        public ActionResult CreateOrUpdate(LabourFormViewModel viewModel) // model binding
        {
            viewModel.Labour.Name = System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(viewModel.Labour.Name.ToLower());
            if (viewModel.UserLogin.Id == 0) // Create
            {
                viewModel.Labour.JoiningDate = DateTime.Now;
                viewModel.UserLogin.UserType = Entities.UserType.Labour;

                userLoginRepository.Insert(viewModel.UserLogin);
                viewModel.Labour.FakeId = viewModel.UserLogin.Id;
                labourRepository.Insert(viewModel.Labour);
                viewModel.LabourServiceMap.LabourId = viewModel.Labour.Id;
                labourServiceMapRepository.Insert(viewModel.LabourServiceMap);

                return(RedirectToAction("LabourList", "Labour"));
            }
            else // Update
            {
                var labour    = labourRepository.Update(viewModel.Labour);
                var userLogin = userLoginRepository.Update(viewModel.UserLogin);
                return(RedirectToAction("Details", "Labour", new { id = viewModel.Labour.FakeId }));
            }
        }