Ejemplo n.º 1
0
        public ActionResult ShowFormPaySlip(SalaryTypeModel model, List <SalaryElementModel> listModel)
        {
            SalaryPaySlipViewModel salaryPaySlip = new SalaryPaySlipViewModel();

            salaryPaySlip.SalaryElements = listModel;
            salaryPaySlip.IsViewOrder    = true;
            salaryPaySlip.IsSave         = true;
            return(PartialView(UrlHelpers.View("~/Views/Shared/_SalaryPaySlip.cshtml"), salaryPaySlip));
        }
Ejemplo n.º 2
0
        public ActionResult SaveSalaryType(SalaryTypeModel model, List <SalaryElementModel> listModel)
        {
            var    result             = new HrmResultModel <SalaryTypeModel>();
            string responeseResources = string.Empty;

            model.CreatedBy = CurrentUser.UserId;
            model.UpdatedBy = CurrentUser.UserId;

            if (model != null)
            {
                var validations = ValidationHelper.Validation(model, "model");
                if (validations.Count > 0)
                {
                    return(Json(new { Result = validations, Invalid = true }, JsonRequestBehavior.AllowGet));
                }
            }
            List <SalarytypeMapperModel> listModelSalarytypeMapper = new List <SalarytypeMapperModel>();

            if (model.ListOrganization != null && model.ListOrganization.Count() > 0)
            {
                foreach (var item in model.ListOrganization)
                {
                    SalarytypeMapperModel salary = new SalarytypeMapperModel();
                    salary.DataId = long.Parse(item);
                    salary.TypeId = MasterDataId.TypeOrganization;
                    listModelSalarytypeMapper.Add(salary);
                }
            }
            var modelEntity          = MapperHelper.Map <SalaryTypeModel, SalaryTypeEntity>(model);
            var listType             = MapperHelper.MapList <SalaryElementModel, SalaryElementType>(listModel);
            var listSalarytypeMapper = MapperHelper.MapList <SalarytypeMapperModel, SalarytypeMapperType>(listModelSalarytypeMapper);
            var responseSave         = _salaryTypeService.SaveSalaryType(modelEntity, listType, listSalarytypeMapper);

            if (responseSave != null)
            {
                result = JsonConvert.DeserializeObject <HrmResultModel <SalaryTypeModel> >(responseSave);
                if (!CheckPermission(result))
                {
                    //return to Access Denied
                }
                else
                {
                    if (result.Results.Count() > 0 && result.Results.FirstOrDefault().Id != 0)
                    {
                        if (model.Id != 0)
                        {
                            responeseResources = _localizationService.GetResources("Message.Update.UnSuccessful");
                        }
                        else
                        {
                            responeseResources = _localizationService.GetResources("Message.Create.UnSuccessfu");
                        }
                        result.Success = false;
                    }
                    else
                    {
                        if (model.Id != 0)
                        {
                            responeseResources = _localizationService.GetResources("Message.Update.Successful");
                        }
                        else
                        {
                            responeseResources = _localizationService.GetResources("Message.Create.Successful");
                        }
                        result.Success = true;
                    }
                }
            }
            return(Json(new { result, responeseResources }, JsonRequestBehavior.AllowGet));
        }