Beispiel #1
0
        public void Create(PayrollGroupModel model, out Guid payrollGroupId)
        {
            if (this._repoPayrollGroup.Query().Filter(x => x.code == model.code).Get().Any())
            {
                throw new Exception(model.code + " is already exists");
            }
            var currentUserId = this.GetCurrentUserId();
            var ins           = this._repoPayrollGroup.Insert(new mf_PayrollGroup()
            {
                code        = model.code,
                description = model.description,
                updatedBy   = currentUserId,
            });

            this._unitOfWork.Save();
            payrollGroupId = ins.id;
        }
Beispiel #2
0
        public void Update(PayrollGroupModel model)
        {
            var upt = this._repoPayrollGroup.Find(model.id);

            if (upt.code != model.code)
            {
                if (this._repoPayrollGroup.Query().Filter(x => x.code == model.code).Get().Any())
                {
                    throw new Exception(model.code + " is already exists");
                }
                upt.code = model.code;
            }
            upt.description = model.description;
            upt.updatedBy   = this.GetCurrentUserId();
            upt.updatedDate = DateTime.Now;
            this._repoPayrollGroup.Update(upt);
            this._unitOfWork.Save();
        }
        //protected override void DeleteRecord()
        //{
        //    base.DeleteRecord();
        //    var id = Convert.ToInt32(recordId.Text);
        //    using (var facade = new EmployeeCore())
        //    {
        //        facade.Delete(id);
        //        ShowMessage(facade);
        //    }
        //}

        private IPayrollGroupModel PopulatePayrollGroupModelFromInterface()
        {
            var payrollGroup = new PayrollGroupModel
            {
                Id          = Convert.ToInt32((recordId.Text.Equals(DefaultValue.AUTO_GENERATE_TEXT) ? "0" : recordId.Text)),
                Name        = groupName.Text,
                Code        = groupCode.Text,
                Type        = groupType.SelectedText,
                Basic       = Convert.ToDecimal(basicSalary.Text),
                Unit        = Convert.ToByte(unit.Text),
                StartDate   = startActiveDate.Value,
                EndDate     = endActiveDate.Value,
                Description = description.Text,
                CreatedBy   = mainConfiguration.CurrentUserName,
                CreatedDate = CurrentDate
            };

            return(payrollGroup);
        }
Beispiel #4
0
        //protected override void DeleteRecord()
        //{
        //    base.DeleteRecord();
        //    var id = Convert.ToInt32(recordId.Text);
        //    using (var facade = new EmployeeCore())
        //    {
        //        facade.Delete(id);
        //        ShowMessage(facade);
        //    }
        //}

        private IPayrollGroupModel PopulatePayrollGroupModelFromInterface()
        {
            IPayrollGroupModel payrollGroup = new PayrollGroupModel();

            payrollGroup.Id          = Convert.ToInt32((recordId.Text.Equals("") ? "0" : recordId.Text));
            payrollGroup.Name        = groupName.Text;
            payrollGroup.Code        = groupCode.Text;
            payrollGroup.Type        = groupType.SelectedText;
            payrollGroup.Basic       = Convert.ToDecimal(basicSalary.Text);
            payrollGroup.Unit        = Convert.ToByte(unit.Text);
            payrollGroup.StartDate   = startActiveDate.Value;
            payrollGroup.EndDate     = endActiveDate.Value;
            payrollGroup.Description = description.Text;

            payrollGroup.CreatedBy    = "";
            payrollGroup.CreatedDate  = DateTime.Now;
            payrollGroup.ModifiedBy   = "";
            payrollGroup.ModifiedDate = DateTime.Now;

            return(payrollGroup);
        }
        public ActionResult PayrollGroupCRUD([DataSourceRequest] DataSourceRequest request
                                             , UpdateType updateType
                                             , PayrollGroupModel model)
        {
            if (model != null && ModelState.IsValid)
            {
                try
                {
                    switch (updateType)
                    {
                    case UpdateType.Create:
                        Guid payrollGroupId;
                        this._payrollGroupService.Create(model, out payrollGroupId);
                        model.id = payrollGroupId;
                        break;

                    case UpdateType.Update:
                        this._payrollGroupService.Update(model);
                        break;

                    case UpdateType.Destroy:
                        this._payrollGroupService.Delete(model.id.Value);
                        break;

                    default:
                        break;
                    }
                }
                catch (Exception ex)
                {
                    this.AddModelError(ex);
                }
            }
            if (model.id.HasValue && updateType != UpdateType.Destroy)
            {
                model = this._payrollGroupService.GetById(model.id.Value);
            }
            return(Json(new[] { model }.ToDataSourceResult(request, ModelState)));
        }