コード例 #1
0
        public ActionResult Update(MZoneEmployee viewModel, FormCollection formCollection)
        {
            MZoneEmployee zoneEmployee = _mZoneEmployeeRepository.Get(viewModel.Id);

            zoneEmployee.EmployeeId = _mEmployeeRepository.Get(formCollection["EmployeeId"]);

            zoneEmployee.StartDate = Helper.CommonHelper.ConvertToDate(formCollection["StartDate"]);
            zoneEmployee.EndDate   = Helper.CommonHelper.ConvertToDate(formCollection["EndDate"]);

            zoneEmployee.ZoneId = _mZoneRepository.Get(formCollection["ZoneId"]);

            zoneEmployee.ModifiedDate = DateTime.Now;
            zoneEmployee.ModifiedBy   = User.Identity.Name;
            zoneEmployee.DataStatus   = EnumDataStatus.Updated.ToString();

            _mZoneEmployeeRepository.Update(zoneEmployee);

            try
            {
                _mZoneEmployeeRepository.DbContext.CommitChanges();
            }
            catch (Exception e)
            {
                _mZoneEmployeeRepository.DbContext.RollbackTransaction();

                return(Content(e.GetBaseException().Message));
            }

            return(Content("Data Pembagian Wilayah Kerja Berhasil Diupdate"));
        }
コード例 #2
0
        public ActionResult Insert(MZoneEmployee viewModel, FormCollection formCollection)
        {
            var zoneEmployee = new MZoneEmployee();

            zoneEmployee.EmployeeId = _mEmployeeRepository.Get(formCollection["EmployeeId"]);

            zoneEmployee.StartDate = Helper.CommonHelper.ConvertToDate(formCollection["StartDate"]);
            zoneEmployee.EndDate   = Helper.CommonHelper.ConvertToDate(formCollection["EndDate"]);

            zoneEmployee.SetAssignedIdTo(Guid.NewGuid().ToString());
            zoneEmployee.CreatedDate = DateTime.Now;
            zoneEmployee.CreatedBy   = User.Identity.Name;
            zoneEmployee.DataStatus  = EnumDataStatus.New.ToString();

            zoneEmployee.ZoneId = _mZoneRepository.Get(formCollection["ZoneId"]);

            _mZoneEmployeeRepository.Save(zoneEmployee);

            try
            {
                _mZoneEmployeeRepository.DbContext.CommitChanges();
            }
            catch (Exception e)
            {
                _mZoneEmployeeRepository.DbContext.RollbackTransaction();

                //throw e.GetBaseException();
                return(Content(e.GetBaseException().Message));
            }

            return(Content("Data Pembagian Wilayah Kerja Berhasil Disimpan"));
        }
コード例 #3
0
        public ActionResult Delete(MZoneEmployee viewModel, FormCollection formCollection)
        {
            MZoneEmployee zoneEmployee = _mZoneEmployeeRepository.Get(viewModel.Id);

            if (zoneEmployee != null)
            {
                _mZoneEmployeeRepository.Delete(zoneEmployee);
            }

            try
            {
                _mZoneEmployeeRepository.DbContext.CommitChanges();
            }
            catch (Exception e)
            {
                _mZoneEmployeeRepository.DbContext.RollbackTransaction();

                return(Content(e.GetBaseException().Message));
            }

            return(Content("Data Pembagian Wilayah Kerja Berhasil Dihapus"));
        }