Example #1
0
        public IHttpActionResult SaveeFleetMaintenance(eFleetMaintenanceModelForApiService objeeFleetMaintenanceModel)
        {
            //var ObjMaintenanceManager = new MaintenanceManager();
            var ObjServiceResponseModel = new ServiceResponseModel <string>();

            try
            {
                if (objeeFleetMaintenanceModel != null && objeeFleetMaintenanceModel.ServiceAuthKey != null && objeeFleetMaintenanceModel.UserId > 0)
                {
                    var ObjRespnse = _IEfleetMaintenance.InsertMaintenance(objeeFleetMaintenanceModel);
                    return(Ok(ObjRespnse));
                }
                else
                {
                    ObjServiceResponseModel.Response = Convert.ToInt32(ServiceResponse.FailedResponse, CultureInfo.CurrentCulture);
                    ObjServiceResponseModel.Message  = CommonMessage.InvalidUser();
                    return(Ok(ObjServiceResponseModel));
                }
            }
            catch (Exception ex)
            {
                ObjServiceResponseModel.Message  = ex.Message;
                ObjServiceResponseModel.Response = Convert.ToInt32(ServiceResponse.ExeptionResponse, CultureInfo.CurrentCulture);
                ObjServiceResponseModel.Data     = null;
                return(Ok(ObjServiceResponseModel));
            }
        }
Example #2
0
        /// <summary>Save eFleet  Maintenance
        /// <CreatedBy>Bhushan Dod</CreatedBy>
        /// <CreatedFor>SaveeFleetMaintenance</CreatedFor>
        /// <CreatedOn>September-20-2017</CreatedOn>
        /// </summary>
        /// <param name="objModel"></param>
        /// <returns></returns>
        public ServiceResponseModel <string> InsertMaintenance(eFleetMaintenanceModelForApiService objModel)
        {
            var objReturnModel = new ServiceResponseModel <string>();

            try
            {
                var objeFleetMaintenanceRepository = new eFleetMaintenanceRepository();
                eFleetMaintenance Obj = new eFleetMaintenance();
                AutoMapper.Mapper.CreateMap <eFleetMaintenanceModelForApiService, eFleetMaintenance>();
                Obj             = AutoMapper.Mapper.Map(objModel, Obj);
                Obj.CreatedBy   = objModel.UserId;
                Obj.CreatedDate = DateTime.UtcNow;
                objeFleetMaintenanceRepository.Add(Obj);
                if (Obj.MaintenanceID > 0)
                {
                    if (Obj.MaintenanceType == 445 && objModel.PmID != null && objModel.PmID > 0)
                    {
                        var objeFleetPreventativeMaintenanceRepository = new eFleetPreventativeMaintenanceRepository();
                        var pmData = objeFleetPreventativeMaintenanceRepository.GetAll(pm => pm.ID == objModel.PmID && pm.LocationID == objModel.LocationID && pm.IsDeleted == false).FirstOrDefault();
                        if (pmData != null && pmData.ID > 0)
                        {
                            pmData.IsCompleted = true;
                            pmData.CompletedBy = objModel.UserId;
                            pmData.CompletedOn = DateTime.UtcNow;

                            objeFleetPreventativeMaintenanceRepository.Update(pmData);
                            objReturnModel.Response = Convert.ToInt32(ServiceResponse.SuccessResponse, CultureInfo.InvariantCulture);
                            objReturnModel.Message  = CommonMessage.Successful();
                        }
                        else
                        {
                            objReturnModel.Response = Convert.ToInt32(ServiceResponse.NoRecord, CultureInfo.InvariantCulture);
                            objReturnModel.Message  = CommonMessage.NoRecordMessage();
                        }
                    }
                    else
                    {
                        objReturnModel.Response = Convert.ToInt32(ServiceResponse.SuccessResponse, CultureInfo.InvariantCulture);
                        objReturnModel.Message  = CommonMessage.Successful();
                    }
                }
            }
            catch (Exception ex)
            {
                WorkOrderEMS.BusinessLogic.Exception_B.Exception_B.exceptionHandel_Runtime(ex, "ServiceResponseModel<string> InsertMaintenance(eFleetMaintenanceModel objModel)", "while insert maintenance", objModel);
                objReturnModel.Message  = ex.Message;
                objReturnModel.Response = Convert.ToInt32(ServiceResponse.ExeptionResponse, CultureInfo.CurrentCulture);
                objReturnModel.Data     = null;
            }
            return(objReturnModel);
        }