Exemple #1
0
 public HttpResponseMessage Edit(decimal id, OverTimePersonDetailProxy viewModel)
 {
     try
     {
         OverTimePersonDetailBusiness.UpdateOverTimePersonDetailByAdministrative(id, viewModel, ApprovalScheduleType.Administrative, BUser.CurrentUser.Person.ID);
         return(Request.CreateResponse(HttpStatusCode.OK, viewModel));
     }
     catch (UIValidationExceptions ex)
     {
         this.exceptionHandler.ApiHandleException("OverTimeEdariController", ex);
         return(Request.CreateResponse(HttpStatusCode.NotFound, ex.ExceptionList.Count > 0 ? ex.ExceptionList[0].Message : ex.Message));
     }
     catch (Exception ex)
     {
         this.exceptionHandler.ApiHandleException("OverTimeEdariController", ex);
         return(Request.CreateResponse(HttpStatusCode.NotFound, ex.Message));
     }
 }
Exemple #2
0
        public HttpResponseMessage getItem(decimal id)
        {
            try
            {
                OverTimePersonDetail      overTimePersonDetail = OverTimePersonDetailBusiness.GetByID(id);
                OverTimePersonDetailProxy obj = new OverTimePersonDetailProxy();

                obj.Id             = overTimePersonDetail.ID;
                obj.Date           = overTimePersonDetail.OverTime.Date;
                obj.PersonFullName = overTimePersonDetail.Person.FirstName + " " + overTimePersonDetail.Person.LastName;

                //------------------------------------------------------------------------------------------------------
                obj.HasOverTime    = overTimePersonDetail.Person.PersonTASpec.OverTimeWork;
                obj.HasHolidayWork = overTimePersonDetail.Person.PersonTASpec.HolidayWork;
                obj.HasNightWork   = overTimePersonDetail.Person.PersonTASpec.NightWork;

                if (obj.HasOverTime)
                {
                    obj.MaxOverTime = overTimePersonDetail.MaxOverTime;
                }
                if (obj.HasNightWork)
                {
                    obj.MaxNightWork = overTimePersonDetail.MaxNightly;
                }
                if (obj.HasHolidayWork)
                {
                    obj.MaxHolidayWork = overTimePersonDetail.MaxHoliday;
                }
                //--------------------------------------------------------------------------------------------------------
                var pDate        = new GTS.Clock.Infrastructure.Utility.PersianDateTime(overTimePersonDetail.OverTime.Date);
                var ArchiveValue = UpdateCalculationResultBusiness.GetArchiveValues(pDate.Year, pDate.Month, overTimePersonDetail.Person.ID).FirstOrDefault();
                if (ArchiveValue != null)
                {
                    obj.P1              = obj.P1Old = ArchiveValue.P1;
                    obj.P2              = obj.P2Old = ArchiveValue.P2;
                    obj.P3              = obj.P3Old = string.IsNullOrEmpty(ArchiveValue.P3.Trim()) ? "00:00" : ArchiveValue.P3;
                    obj.P4              = obj.P4Old = string.IsNullOrEmpty(ArchiveValue.P4.Trim()) ? "00:00" : ArchiveValue.P4;
                    obj.P5              = obj.P5Old = string.IsNullOrEmpty(ArchiveValue.P5.Trim()) ? "00:00" : ArchiveValue.P5;
                    obj.P6              = obj.P6Old = ArchiveValue.P6;
                    obj.P7              = obj.P7Old = ArchiveValue.P7;
                    obj.P8              = obj.P8Old = ArchiveValue.P8;
                    obj.P9              = obj.P9Old = ArchiveValue.P9;
                    obj.P10             = obj.P10Old = string.IsNullOrEmpty(ArchiveValue.P10.Trim()) ? "00:00" : ArchiveValue.P10;
                    obj.P11             = obj.P11Old = ArchiveValue.P11;
                    obj.P12             = obj.P12Old = string.IsNullOrEmpty(ArchiveValue.P12.Trim()) ? "00:00" : ArchiveValue.P12;
                    obj.IsArchiveEnable = true;
                }
                //--------------------------------------------------------------------------------------------------------

                return(Request.CreateResponse(HttpStatusCode.OK, obj));
            }
            catch (UIValidationExceptions ex)
            {
                this.exceptionHandler.ApiHandleException("OverTimeEdariController", ex);
                return(Request.CreateResponse(HttpStatusCode.NotFound, ex.ExceptionList.Count > 0 ? ex.ExceptionList[0].Message : ex.Message));
            }
            catch (Exception ex)
            {
                this.exceptionHandler.ApiHandleException("OverTimeEdariController", ex);

                return(Request.CreateResponse(HttpStatusCode.OK, new OverTimePersonDetailViewModel()));
            }
        }