コード例 #1
0
        public int? CreateUpdateGuardPayment(GuardPaymentViewModel guardPaymentViewModel)
        {
            GuardPayment guardPayment = null;

            if (guardPaymentViewModel.GuardPaymentId > 0)
            {
                guardPayment = _repository.Find<GuardPayment>(x => x.GuardPaymentId == guardPaymentViewModel.GuardPaymentId);
                if (guardPayment == null)
                    return null;

                guardPayment.GuardId = guardPaymentViewModel.GuardId;
                guardPayment.PaymentDate = guardPaymentViewModel.PaymentDate;
                guardPayment.StartDate = guardPaymentViewModel.StartDate;
                guardPayment.EndDate = guardPaymentViewModel.EndDate;
                guardPayment.Amount = guardPaymentViewModel.Amount;
                guardPayment.TotalHours = guardPaymentViewModel.TotalHours;
                guardPayment.HourlyRate = guardPaymentViewModel.HourlyRate;
                guardPayment.Comments = guardPaymentViewModel.Comments;
                guardPayment.ModifiedBy = guardPaymentViewModel.ModifiedBy;
                guardPayment.ModifiedDate = DateTime.Now;

                _repository.Modify<GuardPayment>(guardPayment);
                return guardPayment.GuardPaymentId;
            }

            Mapper.CreateMap<GuardPaymentViewModel, GuardPayment>();
            guardPayment = Mapper.Map<GuardPaymentViewModel, GuardPayment>(guardPaymentViewModel);

            guardPayment.CreatedDate = DateTime.Now;
            guardPayment.CreatedBy = guardPaymentViewModel.CreatedBy;
            guardPayment.IsDeleted = false;
            return _repository.Insert<GuardPayment>(guardPayment);
        }
コード例 #2
0
 public ActionResult CreateUpdateGuardPaymentPopup(int id)
 {
     var guardPayment = _guardPaymentComponent.GetGuardPayment(id);
     if (guardPayment == null)
         guardPayment = new GuardPaymentViewModel();
     guardPayment.GuardList = new SelectList(_guardComponent.GetAllGaurd(), "GuardId", "NameSSN");
     //customerPayment.InvoiceList = new SelectList(_customerInvoiceComponent.GetAllCustomerInvoice(), "InvoiceId", "InvoiceNo");
     return PartialView("/Views/Shared/Partials/_GuardPayment.cshtml", guardPayment);
 }
コード例 #3
0
        public GuardPaymentViewModel GetPaymentAmount(string startDate, string endDate, int guardId)
        {
            using (SecurityAgencyEntities objContext = new SecurityAgencyEntities())
            {
                DateTime _startDate = Convert.ToDateTime(startDate);
                DateTime _endDate = Convert.ToDateTime(endDate);
                //Get Guard Hourly Rate
                //GuardHourlyRate objectGuardHourlyRate = _repository.GetAll<GuardHourlyRate>().Where(x => x.GuardId == guardId).OrderByDescending(i => i.HourlyRateId).FirstOrDefault();
                //Get Last Start and End Date
                GuardPayment objectGuardPayment = objContext.GuardPayments.Where(i => i.GuardId == guardId && i.IsDeleted == false).OrderByDescending(i => i.EndDate).FirstOrDefault();
                Guard objectGuard = objContext.Guards.Where(i => i.GuardId == guardId).FirstOrDefault();
                if (objectGuardPayment != null)
                {
                    _startDate = objectGuardPayment.EndDate;
                    _endDate = objectGuardPayment.EndDate.AddDays(7);
                }
                List<GuardPaymentViewModel> guardPaymentViewModel = (from dailyLog in objContext.DailyLogs                                                                
                                                                 where (dailyLog.Dated > _startDate && dailyLog.Dated < _endDate)
                                                                 && (dailyLog.IsDeleted == false)
                                                                 && dailyLog.GuardId == guardId
                                                                 select new GuardPaymentViewModel
                                                                {
                                                                    TotalHours = dailyLog.Hours,
                                                                }).ToList();

                if (guardPaymentViewModel == null)
                    return null;

                GuardPaymentViewModel objectGuardPaymentViewModel = new GuardPaymentViewModel();
                objectGuardPaymentViewModel.HourlyRate = objectGuard.HourlyRate;
                objectGuardPaymentViewModel.TotalHours = guardPaymentViewModel.Sum(i => i.TotalHours);
                objectGuardPaymentViewModel.Amount = objectGuardPaymentViewModel.TotalHours * objectGuard.HourlyRate;
                objectGuardPaymentViewModel.StartDate = _startDate;
                objectGuardPaymentViewModel.EndDate = _endDate;
                return objectGuardPaymentViewModel;
            }


        }
コード例 #4
0
        public ActionResult CreateUpdateGuardPayment(GuardPaymentViewModel guardPaymentViewModel)
        {
           
                ActiveUser activeUser = new JavaScriptSerializer().Deserialize<ActiveUser>(System.Web.HttpContext.Current.User.Identity.Name);
                guardPaymentViewModel.CreatedBy = activeUser.UserId;
                guardPaymentViewModel.ModifiedBy = activeUser.UserId;

                var result = _guardPaymentComponent.CreateUpdateGuardPayment(guardPaymentViewModel);

                return Json(result, JsonRequestBehavior.AllowGet);
        }