Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Created By Ashwajit Bansod Dated : Sept-22-2017
        /// For Saving and editing Maintenance Report
        /// </summary>
        /// <param name="objeFleetMaintenanceModel"></param>
        /// <returns></returns>
        public eFleetMaintenanceModel SaveEfleetMaintenance(eFleetMaintenanceModel objeFleetMaintenanceModel)
        {
            try
            {
                LocationMaster objLocationMaster              = new LocationMaster();
                var            objeFleetMaintenance           = new eFleetMaintenance();
                var            objeFleetMaintenanceRepository = new eFleetMaintenanceRepository();
                var            objeTracLoginModel             = new eTracLoginModel();
                if (objeFleetMaintenanceModel.MaintenanceID == 0)
                {
                    AutoMapper.Mapper.CreateMap <eFleetMaintenanceModel, eFleetMaintenance>();
                    var objfleetMaintenanceMapper = AutoMapper.Mapper.Map(objeFleetMaintenanceModel, objeFleetMaintenance);
                    objeFleetMaintenanceRepository.Add(objfleetMaintenanceMapper);
                    //objeFleetDriver.QRCCodeID = objeFleetMaintenanceModel.QRCCodeID + "EFD" + (objeFleetDriver.DriverID + 100).ToString();
                    objeFleetMaintenanceRepository.SaveChanges();
                    if (objeFleetMaintenance.MaintenanceID > 0)
                    {
                        if (objeFleetMaintenance.MaintenanceType == 445 && objeFleetMaintenanceModel.PmID != null && objeFleetMaintenanceModel.PmID > 0)
                        {
                            var objeFleetPreventativeMaintenanceRepository = new eFleetPreventativeMaintenanceRepository();
                            var pmData = objeFleetPreventativeMaintenanceRepository.GetAll(pm => pm.ID == objeFleetMaintenanceModel.PmID && pm.LocationID == objeFleetMaintenanceModel.LocationID && pm.IsDeleted == false).FirstOrDefault();
                            if (pmData != null && pmData.ID > 0)
                            {
                                pmData.IsCompleted = true;
                                pmData.CompletedBy = objeFleetMaintenanceModel.UserID;
                                pmData.CompletedOn = DateTime.UtcNow;
                                objeFleetPreventativeMaintenanceRepository.Update(pmData);
                            }
                        }
                        //    objeFleetMaintenanceModel.Result = Result.Completed;
                        if (objeFleetMaintenanceModel.Result == Result.Completed)
                        {
                            #region Save DAR
                            DARModel objDAR = new DARModel();
                            objDAR.ActivityDetails = DarMessage.RegisterNeweFleetMaintenance(objeTracLoginModel.LocationNames);
                            objDAR.LocationId      = objeFleetMaintenanceModel.LocationID;
                            objDAR.UserId          = objeFleetMaintenanceModel.UserID;
                            objDAR.CreatedBy       = objeFleetMaintenanceModel.UserID;
                            objDAR.CreatedOn       = DateTime.UtcNow;
                            objDAR.TaskType        = (long)TaskTypeCategory.eFleetDriverSubmission;
                            Result result = _ICommonMethod.SaveDAR(objDAR);
                            #endregion Save DAR
                        }
                    }
                }
                //edit Data
                else
                {
                    var MaintenanceData = objeFleetMaintenanceRepository.GetAll(v => v.IsDeleted == false && v.MaintenanceID == objeFleetMaintenanceModel.MaintenanceID && v.LocationID == objeFleetMaintenanceModel.LocationID).SingleOrDefault();
                    //objeFleetDriverModel.QRCCodeID = MaintenanceData.QRCCodeID;
                    //objeFleetDriverModel.DriverImage = MaintenanceData.DriverImage;//== null ? "" : HostingPrefix + ProfilePicPath.Replace("~", "") + DriverData.DriverImage;
                    AutoMapper.Mapper.CreateMap <eFleetMaintenanceModel, eFleetMaintenance>();
                    var objfleetDriverMapper = AutoMapper.Mapper.Map(objeFleetMaintenanceModel, MaintenanceData);
                    //objeFleetDriverModel.Passwordforedit = DriverData.Password;
                    objeFleetMaintenanceRepository.SaveChanges();
                    objeFleetMaintenanceModel.Result = Result.UpdatedSuccessfully;

                    if (objeFleetMaintenanceModel.Result == Result.UpdatedSuccessfully)
                    {
                        #region Save DAR
                        DARModel objDAR = new DARModel();
                        objDAR.ActivityDetails = DarMessage.RegisterNeweFleetMaintenance(objeFleetMaintenanceModel.LocationName);
                        objDAR.LocationId      = objeFleetMaintenanceModel.LocationID;
                        objDAR.UserId          = objeFleetMaintenanceModel.UserID;
                        objDAR.ModifiedBy      = objeFleetMaintenanceModel.UserID;
                        objDAR.ModifiedOn      = DateTime.UtcNow;
                        objDAR.TaskType        = (long)TaskTypeCategory.UpdateeFleetMaintenance;
                        Result result = _ICommonMethod.SaveDAR(objDAR);
                        #endregion Save DAR
                    }
                }
                return(objeFleetMaintenanceModel);
            }
            catch (Exception ex)
            {
                Exception_B.Exception_B.exceptionHandel_Runtime(ex, "public eFleetMaintenanceModel SaveEfleetMaintenance(eFleetMaintenanceModel objeFleetMaintenanceModel)", "Exception While saving Maintenance request.", objeFleetMaintenanceModel);
                throw;
            }
        }