Exemple #1
0
 // PUT api/transferdetails/5
 public bool Put(int id, [FromBody] TransferdetailsEntities item)
 {
     if (id > 0)
     {
         return(_TransferDetails.UpdateTransferDetails(id, item));
     }
     return(false);
 }
Exemple #2
0
        public int CreateTransferDetails(TransferdetailsEntities TransferDetailEntities)
        {
            //DateTime? startdate = null;
            var startdate = (DateTime?)null;

            if (TransferDetailEntities.SDATE != null && TransferDetailEntities.SDATE != "")
            {
                startdate = DateTime.ParseExact(TransferDetailEntities.SDATE, "dd/MM/yyyy", CultureInfo.InvariantCulture);
            }
            if (TransferDetailEntities != null)
            {
                var trnsferdata = _UOW.TRANSFER_DETAILSMASTERRepository.GetAll().Where(x => x.EMPLOYEE_ID == TransferDetailEntities.EMPLOYEE_ID).Count();
                if (trnsferdata > 0)
                {
                    var trnsdata = _UOW.TRANSFER_DETAILSMASTERRepository.GetAll().Where(x => x.EMPLOYEE_ID == TransferDetailEntities.EMPLOYEE_ID).ToList().OrderBy(y => y.ID).LastOrDefault();
                    if (trnsdata != null)
                    {
                        if (startdate != null)
                        {
                            trnsdata.TO_DATE = startdate.Value.AddDays(-1);
                        }
                        _UOW.TRANSFER_DETAILSMASTERRepository.Update(trnsdata);
                        _UOW.Save();
                    }
                }
                var TransferDetail = new TBL_EMP_TRANSFER_DETAILS
                {
                    EMPLOYEE_ID      = TransferDetailEntities.EMPLOYEE_ID,
                    DESIGNATION_ID   = TransferDetailEntities.DESIGNATION_ID,
                    WORK_LOCATION    = TransferDetailEntities.WORK_LOCATION,
                    DIVISION         = TransferDetailEntities.DIVISION,
                    SUB_DIVISION     = TransferDetailEntities.SUB_DIVISION,
                    SECTION          = TransferDetailEntities.SECTION,
                    DEPARTMENT       = TransferDetailEntities.DEPARTMENT,
                    REPORTING_PERSON = TransferDetailEntities.REPORTING_PERSON,
                    FROM_DATE        = startdate,
                    STATUS           = TransferDetailEntities.STATUS
                };
                _UOW.TRANSFER_DETAILSMASTERRepository.Insert(TransferDetail);
                _UOW.Save();
            }

            return(Convert.ToInt32(TransferDetailEntities.ID));
        }
Exemple #3
0
 // POST api/transferdetails
 public int Post([FromBody] TransferdetailsEntities item)
 {
     return(_TransferDetails.CreateTransferDetails(item));
 }
Exemple #4
0
        public bool UpdateTransferDetails(int TransferDetailsId, TransferdetailsEntities TransferDetailEntities)
        {
            var success = false;

            if (TransferDetailEntities != null)
            {
                //using (var scope = new TransactionScope())
                //{
                var TransferDetail = _UOW.TRANSFER_DETAILSMASTERRepository.GetByID(TransferDetailsId);
                if (TransferDetail != null)
                {
                    if (TransferDetailEntities.EMPLOYEE_ID != null)
                    {
                        TransferDetail.EMPLOYEE_ID = TransferDetailEntities.EMPLOYEE_ID;
                    }
                    if (TransferDetailEntities.DESIGNATION_ID != null)
                    {
                        TransferDetail.DESIGNATION_ID = TransferDetailEntities.DESIGNATION_ID;
                    }
                    if (TransferDetailEntities.WORK_LOCATION != null)
                    {
                        TransferDetail.WORK_LOCATION = TransferDetailEntities.WORK_LOCATION;
                    }
                    if (TransferDetailEntities.DIVISION != null)
                    {
                        TransferDetail.DIVISION = TransferDetailEntities.DIVISION;
                    }
                    if (TransferDetailEntities.SUB_DIVISION != null)
                    {
                        TransferDetail.SUB_DIVISION = TransferDetailEntities.SUB_DIVISION;
                    }
                    if (TransferDetailEntities.SECTION != null)
                    {
                        TransferDetail.SECTION = TransferDetailEntities.SECTION;
                    }
                    if (TransferDetailEntities.DEPARTMENT != null)
                    {
                        TransferDetail.DEPARTMENT = TransferDetailEntities.DEPARTMENT;
                    }
                    if (TransferDetailEntities.REPORTING_PERSON != null)
                    {
                        TransferDetail.REPORTING_PERSON = TransferDetailEntities.REPORTING_PERSON;
                    }
                    if (TransferDetailEntities.FROM_DATE != null)
                    {
                        TransferDetail.FROM_DATE = TransferDetailEntities.FROM_DATE;
                    }
                    if (TransferDetailEntities.TO_DATE != null)
                    {
                        TransferDetail.TO_DATE = TransferDetailEntities.TO_DATE;
                    }
                    if (TransferDetailEntities.STATUS != null && TransferDetailEntities.STATUS != "")
                    {
                        TransferDetail.STATUS = TransferDetailEntities.STATUS;
                    }
                    _UOW.TRANSFER_DETAILSMASTERRepository.Update(TransferDetail);
                    _UOW.Save();
                    //scope.Complete();
                    success = true;
                    //}
                }
            }
            return(success);
        }