Ejemplo n.º 1
0
        public FIN_ClaimModel Post([Bind] FIN_ClaimModel model)
        {
            #region Validate

            string message       = string.Empty;
            var    checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData <FIN_ClaimModel>(model, "FIN_Claim", ref message);
            if (!checkValidate)
            {
                model.ActionStatus = message;
                return(model);
            }

            #endregion
            ActionService service      = new ActionService(UserLogin);
            string        status       = string.Empty;
            var           baseService  = new BaseService();
            var           clainService = new FIN_ClaimService();
            var           claimEntity  = new FIN_ClaimEntity();
            claimEntity = model.CopyData <FIN_ClaimEntity>();
            clainService.Add(claimEntity);

            var clainItemServices = new FIN_ClaimItemService();
            var lstClaimItem      = new List <FIN_ClaimItemEntity>();
            var objs = new List <object>();
            if (model.TravelRequestID != null)
            {
                objs.Add(model.TravelRequestID.Value);
                var lstRequestItemByRequestID = baseService.GetData <FIN_TravelRequestItemModel>(objs, ConstantSql.hrm_hr_sp_get_TravelRequestItemByTravelRequestID, UserLogin, ref status);
                if (lstRequestItemByRequestID != null)
                {
                    foreach (var item in lstRequestItemByRequestID)
                    {
                        FIN_ClaimItemEntity entity = new FIN_ClaimItemEntity
                        {
                            ClaimID     = claimEntity.ID,
                            Date        = item.Date.Value,
                            Amount      = item == null ? 0 : item.Amount.Value,
                            Description = item.Description,
                        };
                        lstClaimItem.Add(entity);
                    }
                    model.ActionStatus = clainItemServices.Add(lstClaimItem);
                    return(model);
                }
            }

            return(service.UpdateOrCreate <FIN_ClaimEntity, FIN_ClaimModel>(model));
        }
Ejemplo n.º 2
0
        public void ActionSubmit(List <Guid> lstId, string status, Guid userId)
        {
            var    statusMes        = string.Empty;
            var    objTravelRequest = new List <object>();
            string UserLogin        = string.Empty;

            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork            = (IUnitOfWork)(new UnitOfWork(context));
                var repoTravelRequestItem = new CustomBaseRepository <FIN_ClaimItem>(unitOfWork);
                var lstTravelRequestItem  = repoTravelRequestItem.GetAll().Where(s => s.IsDelete == null).ToList();

                var claimID    = lstTravelRequestItem.Where(s => s.ClaimID != null && lstId.Contains(s.ID)).Select(s => s.ClaimID).Distinct().FirstOrDefault();
                var userEntity = GetData <Sys_UserInfoEntity>(userId, ConstantSql.hrm_sys_sp_get_UserbyId, UserLogin, ref statusMes).FirstOrDefault();

                var claimEntity = new FIN_ClaimEntity();
                if (claimID != null)
                {
                    claimEntity = GetData <FIN_ClaimEntity>(claimID.Value, ConstantSql.hrm_hr_sp_get_ClaimById, UserLogin, ref statusMes).FirstOrDefault();
                }

                if (lstId.Count > 0)
                {
                    if (userEntity != null && claimEntity != null)
                    {
                        if (userEntity.ProfileID.Value == claimEntity.ProfileID.Value)
                        {
                            lstTravelRequestItem = lstTravelRequestItem.Where(s => lstId.Contains(s.ID)).ToList();
                            foreach (var item in lstTravelRequestItem)
                            {
                                item.Description2 = status;
                            }
                            repoTravelRequestItem.SaveChanges();
                        }
                    }
                }
            }
        }