Exemplo n.º 1
0
        public void Add(ClaimDTO obj)
        {
            var   permissions = _permissionRepository.GetAllSpecific(obj.Permissions);
            Claim auth        = new Claim(obj.Name, permissions);

            _claimRepository.Add(auth);
            _unitOfWork.Commit();
        }
Exemplo n.º 2
0
 public Claim AddClaim(PeriodId periodId, string employeeNo, string title, DateTime requestDate, ClaimTypeEnum claimTypeId, string request)
 {
     try
     {
         using (var tr = new TransactionScope())
         {
             var id     = claimRep.GetNextId();
             var period = periodRep.GetById(periodId);
             var claim  = new Claim(id, period, employeeNo, title, requestDate, claimTypeId, request);
             claimRep.Add(claim);
             tr.Complete();
             return(claim);
         }
     }
     catch (Exception exp)
     {
         var res = claimRep.TryConvertException(exp);
         if (res == null)
         {
             throw;
         }
         throw res;
     }
 }
Exemplo n.º 3
0
        public ActionResult Save(ClaimViewModel model)
        {
            RePairClaim(model.Claim);
            //var validateWithProject = model.Claim.ValidateDateClaimInfoWithProject();
            //var validateWithClient = model.Claim.CheckClaimClient();
            //var validateWithServer = model.Claim.CheckClaimServer();
            //if (validateWithProject.Count > 0)
            //{
            //    ModelState.AddModelError(string.Empty, "Claim information must in range startdate - enddate");
            //    model.ListClaimInfoError = model.ListClaimInfoError.Union(validateWithProject).ToList();
            //}

            //if (validateWithClient.Count > 0)
            //{
            //    ModelState.AddModelError(string.Empty, "Claim information time range is not valid");
            //    model.ListClaimInfoError = model.ListClaimInfoError.Union(validateWithClient).ToList();
            //}

            //if (validateWithServer.Count > 0)
            //{
            //    ModelState.AddModelError(string.Empty, "Duplicated Claim !There is already claim in this time range.");
            //    model.ListClaimInfoError = model.ListClaimInfoError.Union(validateWithServer).ToList();
            //}

            //if (model.Claim.claimInfos.Count == 0)
            //{
            //    ModelState.AddModelError(string.Empty, "Please add some claim information");
            //}

            if (ModelState.IsValid)
            {
                Claim claim = new Claim()
                {
                    ClaimId          = model.Claim.ClaimId,
                    AuditTrail       = model.Claim.AuditTrail,
                    ProjectId        = model.Claim.ProjectId,
                    Remark           = model.Claim.Remark,
                    Status           = model.Claim.Status,
                    StaffId          = model.Claim.StaffId,
                    TotalWorkingHour = model.Claim.TotalWorkingHour,
                    ClaimInfors      = model.Claim.ClaimInfors
                };
                claim.AuditTrail = claim.AuditTrail ?? "";
                if (model.ClaimAction.Equals("Submit"))
                {
                    claim.Status = (int)ClaimStatus.PendingApproval;
                    if (claim.ClaimId == Guid.Empty)
                    {
                        //submit at first time
                        claim.AuditTrail += "\nSubmitted on << " + DateTime.Now + " >> by << " + User.Identity.GetUserName() + " >>";
                        _claimRepository.Add(claim);
                    }
                    else
                    {
                        //submit at update
                        claim.AuditTrail += "\nUpdated on << " + DateTime.Now + " >> by << " + User.Identity.GetUserName() + " >>";
                        claim.AuditTrail += "\nSubmitted on << " + DateTime.Now + " >> by << " + User.Identity.GetUserName() + " >>";
                        _claimRepository.Update(claim);
                    }
                    //EmailSender.SendReminderAsync(claim);
                }
                else
                {
                    if (claim.ClaimId == Guid.Empty)
                    {
                        //save at first time
                        claim.AuditTrail += "Created on << " + DateTime.Now + " >> by << " + User.Identity.GetUserName() + " >>";
                        _claimRepository.Add(claim);
                    }
                    else
                    {
                        //save at update
                        claim.AuditTrail += "\nUpdated on << " + DateTime.Now + " >> by << " + User.Identity.GetUserName() + " >>";
                        _claimRepository.Update(claim);
                    }
                }
                return(Json(new { IsSuccess = true, ClaimId = claim.ClaimId }));
            }
            GetRelatData(model);
            model.Claim.Status = (int)ClaimStatus.Draft;
            //return PartialView("_PartialFormSaveClaim", model);
            return(View("Create"));
        }