/// <summary> /// To Verify the User /// </summary> /// <CreatedBy>Bhushan Dod</CreatedBy> /// <CreatedDate>2016-10-08</CreatedDate> /// <param name="UserId"></param> /// <param name="DeletedBy"></param> public Result UpdateVerifyUser(long UserId, long ModifiedBy, DARModel objDAR) { Result result; try { ObjUserRepository = new UserRepository(); objCommonMethodManager = new CommonMethodManager(); UserRegistration obj_UserRegistration = ObjUserRepository.GetAll(x => x.UserId == UserId).FirstOrDefault(); if (obj_UserRegistration != null) { obj_UserRegistration.IsLoginActive = true; obj_UserRegistration.IsEmailVerify = true; obj_UserRegistration.ModifiedDate = DateTime.UtcNow; obj_UserRegistration.ModifiedBy = ModifiedBy; ObjUserRepository.SaveChanges(); objDAR.TaskType = (long)TaskTypeCategory.UserUpdate; objDAR.ActivityDetails = DarMessage.UserVerifiedDar(obj_UserRegistration.FirstName + ' ' + obj_UserRegistration.LastName); #region Save DAR result = objCommonMethodManager.SaveDAR(objDAR); #endregion Save DAR return(Result.UpdatedSuccessfully); } else { return(Result.DoesNotExist); } } catch (Exception ex) { throw ex; } }
public bool SaveCostCodeIds(List <long> CostCodeIds, long LocationId, long UserId) { bool IsSaved = false; string action = "I"; string result = ""; var objDAR = new DARModel(); var CommonManager = new CommonMethodManager(); List <string> CostCodedata = new List <string>(); try { if (CostCodeIds.Count > 0) { foreach (var item in CostCodeIds) { var ChildCostCode = _workorderems.CostCodes.Where(x => x.CCD_CostCode == item).FirstOrDefault(); if (ChildCostCode == null) { } else { var saveCostCodeId = _workorderems.spSetCostCodeLocationMapping(action, LocationId, ChildCostCode.CCD_CCM_CostCode, item); IsSaved = true; CostCodedata.Add(ChildCostCode.CCD_Description); } } } var locationName = _workorderems.LocationMasters.Where(x => x.LocationId == LocationId && x.IsDeleted == false).FirstOrDefault(); result = string.Join(",", CostCodedata.ToArray()); #region Save DAR objDAR.ActivityDetails = DarMessage.AllocateCostCodeForLocation(locationName.LocationName, result); objDAR.TaskType = (long)TaskTypeCategory.AllocateCostcode; objDAR.UserId = UserId; objDAR.CreatedBy = UserId; objDAR.LocationId = LocationId; objDAR.DeletedOn = DateTime.UtcNow; CommonManager.SaveDAR(objDAR); #endregion DAR } catch (Exception ex) { Exception_B.Exception_B.exceptionHandel_Runtime(ex, "public bool SaveCostCodeIds(List<long> CostCodeIds, long LocationId)", "Exception While Saving Cost Code to database", LocationId); throw; } return(IsSaved); }
/// <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; } }
/// <summary> /// Created by Ashwait Bansod for Saving data to database and also update data to database /// </summary> /// <param name="objeFleetDriverModel"></param> /// <returns></returns> public eFleetDriverModel SaveEfleetDriver(eFleetDriverModel objeFleetDriverModel) { try { var objLocationMaster = new LocationMaster(); var objeFleetDriver = new eFleetDriver(); var objeFleetDriverRepository = new eFleetDriverRepository(); var objeTracLoginModel = new eTracLoginModel(); if (objeFleetDriverModel.DriverID == 0) { AutoMapper.Mapper.CreateMap <eFleetDriverModel, eFleetDriver>(); var objfleetDriverMapper = AutoMapper.Mapper.Map(objeFleetDriverModel, objeFleetDriver); objeFleetDriverRepository.Add(objfleetDriverMapper); //objeFleetDriver.QRCCodeID = objeFleetDriverModel.QRCCodeID + "EFD" + (objeFleetDriver.DriverID + 100).ToString(); objeFleetDriverRepository.SaveChanges(); objeFleetDriverModel.Result = Result.Completed; if (objeFleetDriverModel.Result == Result.Completed) { #region Save DAR DARModel objDAR = new DARModel(); objDAR.ActivityDetails = DarMessage.RegisterNeweFleetDriver(objeFleetDriverModel.LocationName); objDAR.LocationId = objeFleetDriverModel.LocationID; objDAR.UserId = objeFleetDriverModel.UserID; objDAR.CreatedBy = objeFleetDriverModel.UserID; objDAR.CreatedOn = DateTime.UtcNow; objDAR.TaskType = (long)TaskTypeCategory.eFleetDriverSubmission; Result result = _ICommonMethod.SaveDAR(objDAR); #endregion Save DAR } } //edit Data else { var DriverData = objeFleetDriverRepository.GetAll(v => v.IsDeleted == false && v.DriverID == objeFleetDriverModel.DriverID).FirstOrDefault(); if (objeFleetDriverModel.DriverImageFile != null) { } else { objeFleetDriverModel.DriverImage = DriverData.DriverImage; } //== null ? "" : HostingPrefix + ProfilePicPath.Replace("~", "") + DriverData.DriverImage; AutoMapper.Mapper.CreateMap <eFleetDriverModel, eFleetDriver>(); var objfleetDriverMapper = AutoMapper.Mapper.Map(objeFleetDriverModel, DriverData); objeFleetDriverRepository.SaveChanges(); objeFleetDriverModel.Result = Result.UpdatedSuccessfully; if (objeFleetDriverModel.Result == Result.UpdatedSuccessfully) { #region Save DAR DARModel objDAR = new DARModel(); objDAR.ActivityDetails = DarMessage.UpdateeFleetDriver(objeFleetDriverModel.LocationName); objDAR.LocationId = objeFleetDriverModel.LocationID; objDAR.UserId = objeFleetDriverModel.UserID; objDAR.ModifiedBy = objeFleetDriverModel.UserID; objDAR.ModifiedOn = DateTime.UtcNow; objDAR.TaskType = (long)TaskTypeCategory.UpdateeFleetDriver; Result result = _ICommonMethod.SaveDAR(objDAR); #endregion Save DAR } } return(objeFleetDriverModel); } catch (Exception ex) { Exception_B.Exception_B.exceptionHandel_Runtime(ex, "public eFleetDriverModel SaveEfleetDriver(eFleetDriverModel objeFleetDriverModel)", "Exception While saving Driver request.", objeFleetDriverModel); throw; } }
/// <summary> /// Created By : Ashwajit Bansod /// Created Date : 18-OCT-2018 /// Created for : To approve miscellaneous data. /// </summary> /// <param name="Obj"></param> /// <returns></returns> public bool ApproveMiscellaneous(List <MiscellaneousListModel> Obj, string UserName, long UserId, long LocationId, long MiscQbkId, long VendorDetailsId) { bool IsApproved = false; long MISNumber = 0; decimal? calculatedAmt = 0; string MISID = ""; var objDAR = new DARModel(); var CommonManager = new CommonMethodManager(); DateTime date = new DateTime(); long CreatedBy = 0; long Location = 0; bool GetOnceData = false; var UserDetail = new UserModel(); var LocationDetail = new LocationMaster(); string Status = "Approved"; try { if (Obj.Count > 0) { foreach (var item in Obj) { MISID = item.MISId; string id = item.MISId.Split('S')[1]; MISNumber = Convert.ToInt64(id); calculatedAmt += item.InvoiceAmount; Location = item.LocationId; date = Convert.ToDateTime(item.MISDate); CreatedBy = item.Vendor; objDAR.TaskType = (long)TaskTypeCategory.MiscellaneousReject; if (item.Status == "N") { Status = "Reject"; calculatedAmt -= item.InvoiceAmount; objDAR.TaskType = (long)TaskTypeCategory.MiscellaneousReject; } var saveApprove = _workorderems.spSetApprovalForMiscellaneous(item.MId, item.Comment, item.Status, UserId); if (GetOnceData == false) { GetOnceData = true; UserDetail = _workorderems.UserRegistrations.Join(_workorderems.LogMiscellaneous, u => u.UserId, m => m.LMIS_ModifiedBy, (u, m) => new { u, m }). Where(x => x.m.LMIS_MIS_Id == MISNumber). Select(x => new UserModel() { UserName = x.u.FirstName + " " + x.u.LastName, Email = x.u.UserEmail, Location = x.m.LMIS_LocationId }).FirstOrDefault(); LocationDetail = _workorderems.LocationMasters.Where(x => x.LocationId == UserDetail.Location && x.IsDeleted == false).FirstOrDefault(); } #region Save DAR objDAR.ActivityDetails = DarMessage.MiscellaneousApproveReject(LocationDetail.LocationName, MISID, Status); objDAR.UserId = UserId; objDAR.CreatedBy = UserId; objDAR.LocationId = UserDetail.Location; objDAR.CreatedOn = DateTime.UtcNow; CommonManager.SaveDAR(objDAR); #endregion DAR } string Action = "I"; var saveBill = _workorderems.spSetBill(Action, MiscQbkId, null, MISNumber, null, VendorDetailsId, Location, "MIS", calculatedAmt, calculatedAmt, date, null, CreatedBy, null, "Y"); IsApproved = true; } else { IsApproved = true; } if (IsApproved == true) { #region Email var objEmailLogRepository = new EmailLogRepository(); var objEmailReturn = new List <EmailToManagerModel>(); var objListEmailog = new List <EmailLog>(); var objTemplateModel = new TemplateModel(); if (IsApproved == true) { var userData = _workorderems.UserRegistrations.Join(_workorderems.LogMiscellaneous, u => u.UserId, m => m.LMIS_ModifiedBy, (u, m) => new { u, m }). Where(x => x.m.LMIS_MIS_Id == MISNumber).FirstOrDefault(); //Select(x => new UserModel() //{ // UserName = x.u.FirstName + " " + x.u.LastName, // Email = x.u.UserEmail, // Location = x.m.LMIS_LocationId, //}).FirstOrDefault(); var locationName = _workorderems.LocationMasters.Where(x => x.LocationId == userData.m.LMIS_LocationId && x.IsDeleted == false).FirstOrDefault(); if (userData != null) { bool IsSent = false; var objEmailHelper = new EmailHelper(); objEmailHelper.emailid = userData.u.SubscriptionEmail; objEmailHelper.LocationName = locationName.LocationName; objEmailHelper.UserName = userData.u.FirstName + " " + userData.u.LastName; objEmailHelper.MISId = MISID; objEmailHelper.MailType = "APPROVEMISCELLANEOUS"; objEmailHelper.SentBy = UserId; objEmailHelper.LocationID = userData.m.LMIS_LocationId; objEmailHelper.TimeAttempted = DateTime.UtcNow.ToMobileClientTimeZone(objTemplateModel.TimeZoneName, objTemplateModel.TimeZoneOffset, objTemplateModel.IsTimeZoneinDaylight, false).ToString(); IsSent = objEmailHelper.SendEmailWithTemplate(); //Push Notification if (userData.u.DeviceId != null) { string message = PushNotificationMessages.MiscellaneousApprovedReject(objEmailHelper.LocationName, MISID, Status, objEmailHelper.UserName); PushNotification.GCMAndroid(message, userData.u.DeviceId, objEmailHelper); } if (IsSent == true) { var objEmailog = new EmailLog(); try { objEmailog.CreatedBy = UserId; objEmailog.CreatedDate = DateTime.UtcNow; objEmailog.DeletedBy = null; objEmailog.DeletedOn = null; objEmailog.LocationId = userData.m.LMIS_LocationId; objEmailog.ModifiedBy = null; objEmailog.ModifiedOn = null; objEmailog.SentBy = UserId; objEmailog.SentEmail = userData.u.SubscriptionEmail; objEmailog.Subject = objEmailHelper.Subject; objEmailog.SentTo = userData.u.UserId; objListEmailog.Add(objEmailog); } catch (Exception) { throw; } } using (var context = new workorderEMSEntities()) { context.EmailLogs.AddRange(objListEmailog); context.SaveChanges(); } #endregion Email } } else { IsApproved = true; } } return(IsApproved); } catch (Exception ex) { Exception_B.Exception_B.exceptionHandel_Runtime(ex, "public MiscellaneousListDetails GetListMiscellaneous(long? UserId,long? Location, int? pageIndex, int? numberOfRows, string sortColumnName, string sortOrderBy, long? locationId, string textSearch, string statusType)", "Exception While Getting List of Miscellaneous details.", null); throw; } }
/// <summary> /// Created By : Ashwajit Bansod /// Created Date : 17-OCT-2018 /// Created For : To save Miscellaneous data /// </summary> /// <param name="Obj"></param> /// <returns></returns> public ServiceResponseModel <MiscellaneousDetails> SaveMiscellaneous(MiscellaneousDetails Obj) { bool IsSaved = false; string Action = ""; var objDAR = new DARModel(); List <string> LocationData = new List <string>(); var CommonManager = new CommonMethodManager(); string MISID = ""; string LocationName = ""; long UserId = 0; long Mis_Id = 0; decimal TotalAmount = 0; try { var data = new MiscellaneousDetails(); var ObjServiceResponseModel = new ServiceResponseModel <MiscellaneousDetails>(); if (Obj.MiscellaneousDetailsmodel.Count > 0) { Action = "I"; foreach (var item in Obj.MiscellaneousDetailsmodel) { var SaveMiscData = _workorderems.spSetMiscellaneous(Action, item.MISId, item.CostCode, item.LocationId, item.VendorId, item.Discription, item.InvoiceAmount, item.InvoiceDate, item.InvoiceDocument, item.UserId, null, "Y"); var locData = _workorderems.LocationMasters.Where(x => x.LocationId == item.LocationId && x.IsDeleted == false).FirstOrDefault(); LocationData.Add(locData.LocationName); MISID = "MIS" + item.MISId.ToString(); Mis_Id = item.MISId; UserId = item.UserId; TotalAmount += Convert.ToDecimal(item.InvoiceAmount); IsSaved = true; } if (IsSaved == true) { ObjServiceResponseModel.Response = Convert.ToInt32(ServiceResponse.SuccessResponse, CultureInfo.CurrentCulture); ObjServiceResponseModel.Message = CommonMessage.SaveSuccessMessage(); ObjServiceResponseModel.Data = null; } else { ObjServiceResponseModel.Response = Convert.ToInt32(ServiceResponse.NoRecord, CultureInfo.CurrentCulture); ObjServiceResponseModel.Message = CommonMessage.NoRecordMessage(); ObjServiceResponseModel.Data = null; } #region Save DAR LocationName = string.Join(",", LocationData.ToArray()); objDAR.ActivityDetails = DarMessage.MiscellaneousCreated(LocationName, MISID); objDAR.TaskType = (long)TaskTypeCategory.MiscellaneousCreated; objDAR.UserId = UserId; objDAR.CreatedBy = UserId; objDAR.CreatedOn = DateTime.UtcNow; CommonManager.SaveDAR(objDAR); #endregion DAR #region Notification var objNotify = new NotificationDetailModel(); var _ICommonMethod = new CommonMethodManager(); var objModel = new CommonApproval <ApprovalInput>(); var approvalInput = new ApprovalInput(); approvalInput.Amount = TotalAmount; approvalInput.UserId = UserId; approvalInput.ModuleName = "eCounting"; var getRuleData = objModel.GetApprovalRuleData(approvalInput); if (getRuleData != null) { objNotify.CreatedBy = UserId; objNotify.CreatedDate = DateTime.UtcNow; objNotify.AssignTo = getRuleData.UserId; if (MISID != null) { //var id = Convert.ToInt64(MISID); objNotify.MiscellaneousID = Mis_Id; } var saveDataForNotification = _ICommonMethod.SaveNotificationDetail(objNotify); } if (getRuleData.DeviceId != null) { var objEmailHelper = new EmailHelper(); var objTemplateModel = new TemplateModel(); var userData = _workorderems.UserRegistrations.Where(x => x.UserId == UserId && x.IsDeleted == false && x.IsEmailVerify == true).FirstOrDefault(); objEmailHelper.emailid = getRuleData.Email; objEmailHelper.ManagerName = getRuleData.ManagerName; objEmailHelper.LocationName = LocationName; if (userData != null) { objEmailHelper.UserName = userData.FirstName + " " + userData.LastName; } objEmailHelper.MISId = MISID; //objEmailHelper.InfractionStatus = obj.Status; objEmailHelper.MailType = "APPROVEMISCELLANEOUS"; objEmailHelper.SentBy = UserId; objEmailHelper.LocationID = objDAR.LocationId; objEmailHelper.TimeAttempted = DateTime.UtcNow.ToMobileClientTimeZone(objTemplateModel.TimeZoneName, objTemplateModel.TimeZoneOffset, objTemplateModel.IsTimeZoneinDaylight, false).ToString(); objEmailHelper.IsWorkable = true; if (getRuleData.DeviceId != null) { string message = PushNotificationMessages.MiscellaneousCreate(objNotify.BillID.ToString(), objEmailHelper.UserName, objEmailHelper.LocationName); PushNotificationFCM.FCMAndroid(message, getRuleData.DeviceId, objEmailHelper); } } #endregion Notification return(ObjServiceResponseModel); } else { return(null); } } catch (Exception ex) { Exception_B.Exception_B.exceptionHandel_Runtime(ex, "public ServiceResponseModel<miscellaneousNumberModel> GetMiscellaneousNumberData(ServiceBaseModel ObjServiceBaseModel)", "Exception While Getting Miscellaneous number.", null); throw; } }
/// <summary> /// Created By : Ashwajit Bansod /// Created Date : 26-OCT-2018 /// Created for : To save Payment data to database. /// </summary> /// <param name="objPaymentModel"></param> /// <param name="ObjData"></param> /// <returns></returns> public string MakePayment(PaymentModel objPaymentModel, PaymentModel ObjData) { string result = ""; string Action = ""; string Status = "Y"; string PaidStatus = ""; var objDAR = new DARModel(); var CommonManager = new CommonMethodManager(); try { if (objPaymentModel != null && ObjData != null) { var ChequeNo = Convert.ToInt32(objPaymentModel.ChequeNo); PaidStatus = "Paid"; if (objPaymentModel.ChequeNo != null) { objPaymentModel.Comment = ChequeNo.ToString(); } else if (objPaymentModel.AccNo != null && objPaymentModel.IsCancel == false) { ObjData.VendorId = 0; objPaymentModel.Comment = objPaymentModel.AccNo; } else if (objPaymentModel.CARDNo != null && objPaymentModel.IsCancel == false) { objPaymentModel.Comment = objPaymentModel.CARDNo; } else if (objPaymentModel.AccountNo != null && objPaymentModel.IsCancel == false) { objPaymentModel.Comment = objPaymentModel.AccountNo; } else if (objPaymentModel.Comment != null && objPaymentModel.IsCancel == true) { objPaymentModel.Comment = objPaymentModel.Comment; Status = "X"; PaidStatus = "Canceled"; } Action = "I"; if (objPaymentModel.IsCancel == false) { var savePayment = _workorderems.spSetCompanyAccountTransaction(Action, null, ObjData.VendorId, objPaymentModel.OpeartorCAD_Id, objPaymentModel.CompanyAccountId, ObjData.BillNo, ObjData.BillAmount, ChequeNo, objPaymentModel.Comment, objPaymentModel.UserId, ObjData.LocationId, ObjData.BillType, Status); } if (Status == "Y") { Status = "P"; } var changeStatus = _workorderems.spSetPaymentStatusForBill(ObjData.LLBL_ID, objPaymentModel.Comment, Status, objPaymentModel.UserId); result = CommonMessage.PaymentSave(); } else { result = CommonMessage.PaymentError(); } #region Save DAR var userData = _workorderems.UserRegistrations.Where(x => x.UserId == objPaymentModel.UserId && x.IsDeleted == false && x.IsEmailVerify == true).FirstOrDefault(); var locationData = _workorderems.LocationMasters.Where(x => x.LocationId == ObjData.LocationId && x.IsDeleted == false).FirstOrDefault(); objDAR.ActivityDetails = DarMessage.PaymentPaidCancel(userData.FirstName + "" + userData.LastName, locationData.LocationName, PaidStatus, ObjData.BillNo); long userId = Convert.ToInt64(objPaymentModel.UserId); objDAR.TaskType = (long)TaskTypeCategory.PaymentApporveCancel; objDAR.UserId = userId; objDAR.CreatedBy = userId; objDAR.LocationId = Convert.ToInt64(objPaymentModel.LocationId); objDAR.CreatedOn = DateTime.UtcNow; CommonManager.SaveDAR(objDAR); #endregion DAR } catch (Exception ex) { Exception_B.Exception_B.exceptionHandel_Runtime(ex, "public string MakePayment(PaymentModel objPaymentModel)", "Exception While Saving Payment.", objPaymentModel); throw; } return(result); }
/// <summary>Save eFleet Preventative Maintenance /// <CreatedBy>Bhushan Dod</CreatedBy> /// <CreatedFor>SaveeFleetPreventativeMaintenance</CreatedFor> /// <CreatedOn>August-29-2017</CreatedOn> /// </summary> /// <param name="eFleetDamageTireModel"></param> /// <returns></returns> public ServiceResponseModel <string> InsertPreventativeMaintenance(eFleetPreventaticeMaintenanceModel objModel) { var objReturnModel = new ServiceResponseModel <string>(); try { var objeFleetPreventativeMaintenanceRepository = new eFleetPreventativeMaintenanceRepository(); eFleetPreventativeMaintenance Obj = new eFleetPreventativeMaintenance(); AutoMapper.Mapper.CreateMap <eFleetPreventaticeMaintenanceModel, eFleetPreventativeMaintenance>(); Obj = AutoMapper.Mapper.Map(objModel, Obj); Obj.CreatedBy = objModel.UserId; Obj.CreatedDate = DateTime.UtcNow; objeFleetPreventativeMaintenanceRepository.Add(Obj); if (Obj.ID > 0) { #region Save DAR DARModel objDAR = new DARModel(); objDAR.ActivityDetails = DarMessage.NeweFleetPMCreated(objModel.LocationName); objDAR.LocationId = objModel.LocationID; objDAR.UserId = objModel.UserId; objDAR.CreatedBy = objModel.UserId; objDAR.CreatedOn = DateTime.UtcNow; objDAR.TaskType = (long)TaskTypeCategory.PreventativeMaintenanceSubmission; Result result = _ICommonMethod.SaveDAR(objDAR); #endregion Save DAR #region Email var objEmailLogRepository = new EmailLogRepository(); var objEmailReturn = new List <EmailToManagerModel>(); var objListEmailog = new List <EmailLog>(); var objTemplateModel = new TemplateModel(); if (result == Result.Completed) { objEmailReturn = objEmailLogRepository.SendEmailToManagerForeFleetInspection(objModel.LocationID, objModel.UserId).Result; } if (objEmailReturn.Count > 0 && result == Result.Completed) { foreach (var item in objEmailReturn) { bool IsSent = false; var objEmailHelper = new EmailHelper(); objEmailHelper.emailid = item.ManagerEmail; objEmailHelper.ManagerName = item.ManagerName; objEmailHelper.RemiderMetric = Convert.ToString(objModel.ReminderMetric); objEmailHelper.Meter = Convert.ToString(objModel.Meter); objEmailHelper.VehicleNumber = objModel.VehicleNumber; objEmailHelper.LocationName = objModel.LocationName; objEmailHelper.UserName = item.UserName; objEmailHelper.QrCodeId = objModel.QrCodeId; objEmailHelper.ServiceDueDate = objModel.ServiceDueDate.ToString(); //objEmailHelper.InfractionStatus = obj.Status; objEmailHelper.MailType = "PreventativeMaintenance"; objEmailHelper.SentBy = item.RequestBy; objEmailHelper.LocationID = item.LocationID; objEmailHelper.TimeAttempted = DateTime.UtcNow.ToMobileClientTimeZone(objTemplateModel.TimeZoneName, objTemplateModel.TimeZoneOffset, objTemplateModel.IsTimeZoneinDaylight, false).ToString(); IsSent = objEmailHelper.SendEmailWithTemplate(); //Push Notification string message = PushNotificationMessages.eFleetPreventativeMaintenanceReported(objModel.LocationName, objModel.QrCodeId, objModel.VehicleNumber); PushNotification.GCMAndroid(message, item.DeviceId, objEmailHelper); if (IsSent == true) { var objEmailog = new EmailLog(); try { objEmailog.CreatedBy = item.RequestBy; objEmailog.CreatedDate = DateTime.UtcNow; objEmailog.DeletedBy = null; objEmailog.DeletedOn = null; objEmailog.LocationId = item.LocationID; objEmailog.ModifiedBy = null; objEmailog.ModifiedOn = null; objEmailog.SentBy = item.RequestBy; objEmailog.SentEmail = item.ManagerEmail; objEmailog.Subject = objEmailHelper.Subject; objEmailog.SentTo = item.ManagerUserId; objListEmailog.Add(objEmailog); } catch (Exception) { throw; } } } using (var context = new workorderEMSEntities()) { context.EmailLogs.AddRange(objListEmailog); context.SaveChanges();; } // //var x = EmailLogRepository.InsertEntitiesNew("EmailLog", objListEmailog); // //Task<bool> x = null; // //foreach (var i in objListEmailog) // //{ // // x = objEmailLogRepository.SaveEmailLogAsync(i); // //} //} #endregion Email 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> InsertPreventativeMaintenance(eFleetPreventaticeMaintenanceModel objModel)", "while insert preventative maintenance", objModel); objReturnModel.Message = ex.Message; objReturnModel.Response = Convert.ToInt32(ServiceResponse.ExeptionResponse, CultureInfo.CurrentCulture); objReturnModel.Data = null; } return(objReturnModel); }
public eFleetVehicleIncidentModel SaveEfleetVehicleIncident(eFleetVehicleIncidentModel objeFleetVehicleIncidentModel) { try { LocationMaster objLocationMaster = new LocationMaster(); var objeFleetVehicleIncident = new eFleetVehicleIncident(); var objeFleetVehicleIncidentRepository = new eFleetVehicleIncidentRepository(); var objeTracLoginModel = new eTracLoginModel(); if (objeFleetVehicleIncidentModel.IncidentID == 0) { objeFleetVehicleIncidentModel.IsDeleted = false; AutoMapper.Mapper.CreateMap <eFleetVehicleIncidentModel, eFleetVehicleIncident>(); var objfleetVehicleIncidentMapper = AutoMapper.Mapper.Map(objeFleetVehicleIncidentModel, objeFleetVehicleIncident); objeFleetVehicleIncidentRepository.Add(objfleetVehicleIncidentMapper); // objeFleetVehicle.QRCodeID = objeFleetVehicleModel.QRCodeID + "EFV" + (objeFleetVehicle.VehicleID + 100).ToString(); objeFleetVehicleIncidentRepository.SaveChanges(); objeFleetVehicleIncidentModel.Result = Result.Completed; if (objeFleetVehicleIncidentModel.Result == Result.Completed) { #region Save DAR DARModel objDAR = new DARModel(); objDAR.ActivityDetails = DarMessage.RegisterNeweFleetIncidentVehicle(objeFleetVehicleIncidentModel.LocationName); objDAR.LocationId = objeFleetVehicleIncidentModel.LocationID; objDAR.UserId = objeFleetVehicleIncidentModel.UserID; objDAR.CreatedBy = objeFleetVehicleIncidentModel.UserID; objDAR.CreatedOn = DateTime.UtcNow; objDAR.TaskType = (long)TaskTypeCategory.eFleetVehicleIncidentSubmission; Result result = _ICommonMethod.SaveDAR(objDAR); #endregion Save DAR //Created By Ashwajit Bansod for Sending the Mail of Vehicle Incident to the Manager #region Email var objEmailLogRepository = new EmailLogRepository(); var objEmailReturn = new List <EmailToManagerModel>(); var objListEmailog = new List <EmailLog>(); var objTemplateModel = new TemplateModel(); if (result == Result.Completed) { objEmailReturn = objEmailLogRepository.SendEmailToManagerForeFleetInspection(objeFleetVehicleIncidentModel.LocationID, objeFleetVehicleIncidentModel.UserID).Result; //Code added by Bhu on 14 Dec 2017 for sending email to [email protected]. This is common MRA for risk manager. var objEmailToManagerModel = new EmailToManagerModel(); objEmailToManagerModel.LocationID = objeFleetVehicleIncidentModel.LocationID; objEmailToManagerModel.LocationName = objeFleetVehicleIncidentModel.LocationName; objEmailToManagerModel.ManagerEmail = "*****@*****.**"; objEmailToManagerModel.ManagerName = "Team"; objEmailToManagerModel.ManagerUserId = 3; //admin user id for need to track email log objEmailToManagerModel.RequestBy = 3; //admin user id for need to track email log objEmailToManagerModel.UserName = "******"; objEmailReturn.Add(objEmailToManagerModel); } if (objEmailReturn.Count > 0 && result == Result.Completed) { foreach (var item in objEmailReturn) { bool IsSent = false; var objEmailHelper = new EmailHelper(); objEmailHelper.emailid = item.ManagerEmail; objEmailHelper.ManagerName = item.ManagerName; objEmailHelper.VehicleNumber = objeFleetVehicleIncidentModel.VehicleNumber; objEmailHelper.LocationName = objeFleetVehicleIncidentModel.LocationName; objEmailHelper.UserName = item.UserName; objEmailHelper.QrCodeId = objeFleetVehicleIncidentModel.QRCodeID; objEmailHelper.AccidentDate = objeFleetVehicleIncidentModel.AccidentDate.ToString(); objEmailHelper.City = objeFleetVehicleIncidentModel.City; objEmailHelper.NumberOfInjuries = objeFleetVehicleIncidentModel.NumberOfInjuries; objEmailHelper.DriverNameForVehicleIncident = objeFleetVehicleIncidentModel.DriverName; objEmailHelper.IncidentDescription = objeFleetVehicleIncidentModel.Description; if (objeFleetVehicleIncidentModel.Preventability == true) { objEmailHelper.Prevenatability = "Yes"; } else { objEmailHelper.Prevenatability = "No"; } //objEmailHelper.InfractionStatus = obj.Status; objEmailHelper.MailType = "VehicleIncident"; objEmailHelper.SentBy = item.RequestBy; objEmailHelper.LocationID = item.LocationID; objEmailHelper.TimeAttempted = DateTime.UtcNow.ToMobileClientTimeZone(objTemplateModel.TimeZoneName, objTemplateModel.TimeZoneOffset, objTemplateModel.IsTimeZoneinDaylight, false).ToString(); IsSent = objEmailHelper.SendEmailWithTemplate(); //Push Notification string message = PushNotificationMessages.eFleetIncidentForServiceReported(objeFleetVehicleIncidentModel.LocationName, objeFleetVehicleIncidentModel.QRCodeID, objeFleetVehicleIncidentModel.VehicleNumber); PushNotification.GCMAndroid(message, item.DeviceId, objEmailHelper); if (IsSent == true) { var objEmailog = new EmailLog(); try { objEmailog.CreatedBy = item.RequestBy; objEmailog.CreatedDate = DateTime.UtcNow; objEmailog.DeletedBy = null; objEmailog.DeletedOn = null; objEmailog.LocationId = item.LocationID; objEmailog.ModifiedBy = null; objEmailog.ModifiedOn = null; objEmailog.SentBy = item.RequestBy; objEmailog.SentEmail = item.ManagerEmail; objEmailog.Subject = objEmailHelper.Subject; objEmailog.SentTo = item.ManagerUserId; objListEmailog.Add(objEmailog); } catch (Exception) { throw; } } } using (var context = new workorderEMSEntities()) { context.EmailLogs.AddRange(objListEmailog); context.SaveChanges();; } // //var x = EmailLogRepository.InsertEntitiesNew("EmailLog", objListEmailog); // //Task<bool> x = null; // //foreach (var i in objListEmailog) // //{ // // x = objEmailLogRepository.SaveEmailLogAsync(i); // //} //} #endregion Email } } } else { var vehicleIncidentData = objeFleetVehicleIncidentRepository.GetAll(v => v.IsDeleted == false && v.LocationID == objeFleetVehicleIncidentModel.LocationID && v.IncidentID == objeFleetVehicleIncidentModel.IncidentID).SingleOrDefault(); objeFleetVehicleIncidentModel.IncidentImage = vehicleIncidentData.IncidentImage; AutoMapper.Mapper.CreateMap <eFleetVehicleIncidentModel, eFleetVehicleIncident>(); // objeFleetVehicleIncident.FuelType = Convert.ToInt32(objeFleetVehicleIncidentModel.FuelType); var objfleetVehicleMapper = AutoMapper.Mapper.Map(objeFleetVehicleIncidentModel, vehicleIncidentData); objeFleetVehicleIncidentRepository.SaveChanges(); objeFleetVehicleIncidentModel.Result = Result.UpdatedSuccessfully; if (objeFleetVehicleIncidentModel.Result == Result.UpdatedSuccessfully) { #region Save DAR DARModel objDAR = new DARModel(); objDAR.ActivityDetails = DarMessage.UpdateeFleetVehicleIncident(objeFleetVehicleIncidentModel.LocationName); objDAR.LocationId = objeFleetVehicleIncidentModel.LocationID; objDAR.UserId = objeFleetVehicleIncidentModel.UserID; objDAR.ModifiedBy = objeFleetVehicleIncidentModel.UserID; objDAR.ModifiedOn = DateTime.UtcNow; objDAR.TaskType = (long)TaskTypeCategory.UpdateeFleetIncidentVehicle; Result result = _ICommonMethod.SaveDAR(objDAR); #endregion Save DAR } } return(objeFleetVehicleIncidentModel); } catch (Exception ex) { Exception_B.Exception_B.exceptionHandel_Runtime(ex, "public eFleetVehicleIncidentModel SaveEfleetVehicleIncident(eFleetVehicleIncidentModel objeFleetVehicleIncidentModel)", "Exception While saving vehicle Incident request.", objeFleetVehicleIncidentModel); throw; } }
/// <summary> /// Created By : Ashwajit Bansod /// Created Date : 20-OCT-2018 /// Created For : To approve and reject bill /// </summary> /// <param name="Obj"></param> /// <param name="UserName"></param> /// <param name="UserId"></param> /// <param name="LocationId"></param> /// <returns></returns> public string ApproveBill(BillListApproveModel Obj, string UserName, long UserId, long LocationId) { bool IsApproved = false; string result = ""; var objDAR = new DARModel(); var CommonManager = new CommonMethodManager(); string ApproveStatus = ""; try { var userDataItem = _workorderems.UserRegistrations.Where(x => x.UserId == UserId && x.IsDeleted == false && x.IsEmailVerify == true).FirstOrDefault(); if (Obj != null) { string Action = "I"; if (Obj.Comment == null) { Obj.Status = "Y"; ApproveStatus = "Approved"; } else { Obj.Status = "N"; ApproveStatus = "Rejected"; } var saveBillApprove = _workorderems.spSetApprovalForPreBill(Obj.LBLL_Id, Obj.Comment, Obj.Status, UserId); //var saveApprove = _workorderems.spSetApprovalForBill(Obj.LBLL_Id, Obj.Comment,Obj.Status,UserId); Obj.InvoiceDate = Convert.ToDateTime(Obj.BillDate); var saveSetBill = _workorderems.spSetBill(Action, Obj.QuickBookBillId, null, null, Obj.BillId, Obj.VendorId, LocationId, "Manual Bill", null, Obj.BillAmount, Obj.InvoiceDate, Obj.BillImage, UserId, UserId, "Y"); IsApproved = true; if (Obj.Comment == null) { result = CommonMessage.BillApprove(); } else { result = CommonMessage.BillReject(); } #region Save DAR var locationData = _workorderems.LocationMasters.Where(x => x.LocationId == LocationId && x.IsDeleted == false).FirstOrDefault(); objDAR.ActivityDetails = DarMessage.BillApprovedReject(userDataItem.FirstName + "" + userDataItem.LastName, locationData.LocationName, ApproveStatus); objDAR.TaskType = (long)TaskTypeCategory.BillApprovedReject; objDAR.UserId = UserId; objDAR.CreatedBy = UserId; objDAR.LocationId = LocationId; objDAR.CreatedOn = DateTime.UtcNow; CommonManager.SaveDAR(objDAR); #endregion DAR } else { IsApproved = true; } if (IsApproved == true) { #region Email var objEmailLogRepository = new EmailLogRepository(); var objEmailReturn = new List <EmailToManagerModel>(); var objListEmailog = new List <EmailLog>(); var objTemplateModel = new TemplateModel(); if (IsApproved == true) { var userData = _workorderems.spGetVendorAllDetail(Obj.VendorId). Select(x => new BillListApproveModel() { Email = x.COD_Email, }).FirstOrDefault(); if (userData != null) { bool IsSent = false; var objEmailHelper = new EmailHelper(); objEmailHelper.emailid = userData.Email; objEmailHelper.LocationName = Obj.LocationName; objEmailHelper.VendorName = Obj.VendorName; objEmailHelper.UserName = userDataItem.FirstName + " " + userDataItem.LastName; objEmailHelper.MailType = "APPROVEBILL"; objEmailHelper.SentBy = UserId; objEmailHelper.LocationID = LocationId; objEmailHelper.TimeAttempted = DateTime.UtcNow.ToMobileClientTimeZone(objTemplateModel.TimeZoneName, objTemplateModel.TimeZoneOffset, objTemplateModel.IsTimeZoneinDaylight, false).ToString(); IsSent = objEmailHelper.SendEmailWithTemplate(); var userDataApprove = _workorderems.LogBills.Join(_workorderems.UserRegistrations, q => q.LBLL_ModifiedBy, u => u.UserId, (q, u) => new { q, u }). Where(x => x.q.LBLL_Id == Obj.LBLL_Id).FirstOrDefault(); //Push Notification if (userDataApprove != null) { if (userDataApprove.u.DeviceId != null) { string message = PushNotificationMessages.BillApprovedReject(objEmailHelper.LocationName, Obj.LBLL_Id, ApproveStatus, objEmailHelper.UserName); PushNotification.GCMAndroid(message, userDataApprove.u.DeviceId, objEmailHelper); } } if (IsSent == true) { var objEmailog = new EmailLog(); try { objEmailog.CreatedBy = UserId; objEmailog.CreatedDate = DateTime.UtcNow; objEmailog.DeletedBy = null; objEmailog.DeletedOn = null; objEmailog.LocationId = LocationId; objEmailog.ModifiedBy = null; objEmailog.ModifiedOn = null; objEmailog.SentBy = UserId; objEmailog.SentEmail = userData.Email; objEmailog.Subject = objEmailHelper.Subject; objEmailog.SentTo = Obj.VendorId; objListEmailog.Add(objEmailog); } catch (Exception) { throw; } } using (var context = new workorderEMSEntities()) { context.EmailLogs.AddRange(objListEmailog); context.SaveChanges(); } #endregion Email } } else { result = "Somethinsg goes wrong."; } } return(result); } catch (Exception ex) { Exception_B.Exception_B.exceptionHandel_Runtime(ex, "public MiscellaneousListDetails GetListMiscellaneous(long? UserId,long? Location, int? pageIndex, int? numberOfRows, string sortColumnName, string sortOrderBy, long? locationId, string textSearch, string statusType)", "Exception While Getting List of Miscellaneous details.", null); throw; } }
/// <summary> /// Created By : Ashwajit bansod /// Created Date : 12-OCT-2018 /// Created For : To Save Bill /// </summary> /// <param name="objBillDataServiceModel"></param> /// <returns></returns> public bool SaveBillDetails(BillDataServiceModel objBillDataServiceModel) { bool isBillSaved = false; string Action = ""; string DeliverStatus = ""; var objDAR = new DARModel(); var CommonManager = new CommonMethodManager(); string LocationName = string.Empty; string UserName = string.Empty; try { if (objBillDataServiceModel != null && objBillDataServiceModel.VendorId > 0 && objBillDataServiceModel.LocationId > 0 && objBillDataServiceModel.UserId > 0) { Action = "I"; if (objBillDataServiceModel.PODId > 0) { DeliverStatus = "Y"; var saveBillData = _workorderems.spSetBill(Action, objBillDataServiceModel.QuickBookBillId, objBillDataServiceModel.PODId, null, null, objBillDataServiceModel.VendorId, objBillDataServiceModel.LocationId, objBillDataServiceModel.BillType, objBillDataServiceModel.PoMisBdaAmount, objBillDataServiceModel.InvoiceAmount, objBillDataServiceModel.InvoiceDate, objBillDataServiceModel.InvoiceDocument, objBillDataServiceModel.UserId, null, DeliverStatus); string[] Quantity = { }; string[] POF = { }; string[] ActiveId = objBillDataServiceModel.IsActive.Split(','); if (objBillDataServiceModel.Quantity != null) { Quantity = objBillDataServiceModel.Quantity.Split(','); } if (objBillDataServiceModel.POF_ID != null) { POF = objBillDataServiceModel.POF_ID.Split(','); } if (objBillDataServiceModel.IsActive != "") { for (int i = 0; i < ActiveId.Length; i++) { if (ActiveId[i] != null) { //ActiveId[i] = "N"; Action = "U"; long POF_ID = Convert.ToInt64(POF[i]); long QantityData = Convert.ToInt64(Quantity[i]); long FacilityId = Convert.ToInt64(ActiveId[i]); DeliverStatus = "N"; var saveFacilityData = _workorderems.spSetPOFacilityItem(Action, POF_ID, objBillDataServiceModel.PODId, FacilityId, QantityData, DeliverStatus); } } } var userData = _workorderems.UserRegistrations.Where(x => x.UserId == objBillDataServiceModel.UserId && x.IsDeleted == false && x.IsEmailVerify == true).FirstOrDefault(); var locationData = _workorderems.LocationMasters.Where(x => x.LocationId == objBillDataServiceModel.LocationId && x.IsDeleted == false).FirstOrDefault(); #region Save DAR LocationName = locationData.LocationServices.ToString(); UserName = userData.FirstName + " " + userData.LastName; objDAR.ActivityDetails = DarMessage.BillCreated(userData.FirstName + "" + userData.LastName, locationData.LocationName, objBillDataServiceModel.PODId); objDAR.TaskType = (long)TaskTypeCategory.BillCreated; objDAR.UserId = objBillDataServiceModel.UserId; objDAR.CreatedBy = objBillDataServiceModel.UserId; objDAR.LocationId = objBillDataServiceModel.LocationId; objDAR.CreatedOn = DateTime.UtcNow; CommonManager.SaveDAR(objDAR); #endregion DAR } else { var savePreBill = _workorderems.spSetPreBill(Action, objBillDataServiceModel.BillNumber, objBillDataServiceModel.LocationId, objBillDataServiceModel.VendorId, objBillDataServiceModel.Comment, objBillDataServiceModel.InvoiceAmount, objBillDataServiceModel.InvoiceDate, objBillDataServiceModel.InvoiceDocument, objBillDataServiceModel.UserId, null, "N"); if (objBillDataServiceModel.FacilityListForManualBill != null && objBillDataServiceModel.FacilityListForManualBill.Count() > 0) { foreach (var item in objBillDataServiceModel.FacilityListForManualBill) { if (item.UnitPrice > 0) { var saveFacility = _workorderems.spSetBillFacilityItem(Action, null, objBillDataServiceModel.BillNumber, item.COM_FacilityId, item.Quantity, item.UnitPrice, item.Status); } } } //var saveBillData = _workorderems.spSetBill(Action,null, null, null, // objBillDataServiceModel.VendorId, objBillDataServiceModel.LocationId, // objBillDataServiceModel.BillType, null, // objBillDataServiceModel.InvoiceAmount, objBillDataServiceModel.InvoiceDate, objBillDataServiceModel.InvoiceDocument, // objBillDataServiceModel.UserId, null, "Y"); } var objNotify = new NotificationDetailModel(); var _ICommonMethod = new CommonMethodManager(); var objModel = new CommonApproval <ApprovalInput>(); var approvalInput = new ApprovalInput(); approvalInput.Amount = Convert.ToDecimal(objBillDataServiceModel.InvoiceAmount); approvalInput.UserId = objBillDataServiceModel.UserId; approvalInput.ModuleName = "eCounting"; var getRuleData = objModel.GetApprovalRuleData(approvalInput); if (getRuleData != null) { objNotify.CreatedBy = objBillDataServiceModel.UserId; objNotify.CreatedDate = DateTime.UtcNow; objNotify.AssignTo = getRuleData.UserId; if (objBillDataServiceModel.PODId > 0) { objNotify.BillID = objBillDataServiceModel.PODId; } else { objNotify.BillID = objBillDataServiceModel.BillNumber; } var saveDataForNotification = _ICommonMethod.SaveNotificationDetail(objNotify); } if (getRuleData.DeviceId != null) { var objEmailHelper = new EmailHelper(); var objTemplateModel = new TemplateModel(); objEmailHelper.emailid = getRuleData.Email; objEmailHelper.ManagerName = getRuleData.ManagerName; objEmailHelper.LocationName = LocationName; objEmailHelper.UserName = UserName; objEmailHelper.BillId = objNotify.BillID.ToString(); //objEmailHelper.InfractionStatus = obj.Status; objEmailHelper.MailType = "BILLAPPROVE"; objEmailHelper.SentBy = objBillDataServiceModel.UserId; objEmailHelper.LocationID = objDAR.LocationId; objEmailHelper.TimeAttempted = DateTime.UtcNow.ToMobileClientTimeZone(objTemplateModel.TimeZoneName, objTemplateModel.TimeZoneOffset, objTemplateModel.IsTimeZoneinDaylight, false).ToString(); objEmailHelper.IsWorkable = true; string message = PushNotificationMessages.BillCreate(objNotify.BillID.ToString(), objEmailHelper.UserName, objEmailHelper.LocationName); PushNotificationFCM.FCMAndroid(message, getRuleData.DeviceId, objEmailHelper); } isBillSaved = true; } else { isBillSaved = false; } } catch (Exception ex) { Exception_B.Exception_B.exceptionHandel_Runtime(ex, "public BillDataServiceModel SaveBillDetails(BillDataServiceModel objBillDataServiceModel)", "Exception While Saving Bill Details.", null); throw; } return(isBillSaved); }
/// <summary> /// To Delete the User /// </summary> /// <CreatedBy>Manoj Jaswal</CreatedBy> /// <CreatedDate>2015-03-05</CreatedDate> /// <param name="UserId"></param> /// <param name="DeletedBy"></param> public Result DeleteUser(long UserId, long DeletedBy, DARModel objDAR) { long UserType = 0; Result result; long count = 0; try { ObjUserRepository = new UserRepository(); objCommonMethodManager = new CommonMethodManager(); UserRegistration obj_UserRegistration = ObjUserRepository.GetAll(x => x.UserId == UserId).FirstOrDefault(); if (obj_UserRegistration != null) { UserType = obj_UserRegistration.UserType; using (workorderEMSEntities context = new workorderEMSEntities()) { if (UserType == 6) { count = (from o in context.AdminLocationMappings join ur in context.UserRegistrations on o.AdminUserId equals ur.UserId where ur.IsLoginActive == true && ur.IsEmailVerify == true && ur.IsDeleted == false && ur.UserId == UserId && o.IsDeleted == false select o.AdminUserId ).Count(); } else if (UserType == 2) { count = (from o in context.ManagerLocationMappings join ur in context.UserRegistrations on o.ManagerUserId equals ur.UserId where ur.IsLoginActive == true && ur.IsEmailVerify == true && ur.IsDeleted == false && o.IsDeleted == false && ur.UserId == UserId select o.ManagerUserId ).Count(); } } if (count == 0) { obj_UserRegistration.IsDeleted = true; obj_UserRegistration.IsLoginActive = false; obj_UserRegistration.DeletedDate = DateTime.UtcNow; obj_UserRegistration.DeletedBy = DeletedBy; ObjUserRepository.SaveChanges(); objDAR.TaskType = (long)TaskTypeCategory.UserDelete; objDAR.ActivityDetails = DarMessage.UserDeleteDar(obj_UserRegistration.FirstName + ' ' + obj_UserRegistration.LastName); #region Save DAR result = objCommonMethodManager.SaveDAR(objDAR); #endregion Save DAR return(Result.Delete); } else { return(Result.ExistRecord); } } else { return(Result.DoesNotExist); } } catch (Exception ex) { throw ex; } }
/// <summary> /// To Delete the User permanently /// </summary> /// <CreatedBy>Vijay Sahu</CreatedBy> /// <CreatedDate>2015-06-22</CreatedDate> public Tuple <int, string> DeleteUserFromUserList(long UserId, long DeletedBy, DARModel objDAR) { StringBuilder sb = new StringBuilder(); int count = 0; try { ObjUserRepository = new UserRepository(); CommonMethodManager objCommonMethodManager = new CommonMethodManager(); UserRegistration obj_UserRegistration = ObjUserRepository.GetAll(x => x.UserId == UserId).FirstOrDefault(); if (obj_UserRegistration != null) { //UserType = obj_UserRegistration.UserType; workorderEMSEntities Context = new workorderEMSEntities(); List <ssp_DeleteUser_Result> resu = Context.ssp_DeleteUser(UserId, DeletedBy).ToList(); count = Convert.ToInt32(resu.Select(x => x.Result).FirstOrDefault()); if (count == 0) //--SELECT 0,0,0,'There is one or more than one location where he is only one manager' { sb.Append("You can't delete this user because is the only manager for location(s) "); foreach (var locName in resu) { sb.Append("<strong>" + locName.LocationName + "<strong>, "); } try { if (sb.Length > 2 && sb.ToString().Contains(",")) { sb.Remove(sb.Length - 2, 2).Append("."); } } catch { } } else if (count == 1) //--SELECT 1,0,0,'There is no location where he is only one manager' { obj_UserRegistration.IsDeleted = true; obj_UserRegistration.IsLoginActive = false; obj_UserRegistration.DeletedDate = DateTime.UtcNow; obj_UserRegistration.DeletedBy = DeletedBy; ObjUserRepository.SaveChanges(); objDAR.TaskType = (long)TaskTypeCategory.UserDelete; objDAR.ActivityDetails = DarMessage.UserDeleteDar(obj_UserRegistration.FirstName + ' ' + obj_UserRegistration.LastName); #region Save DAR objCommonMethodManager.SaveDAR(objDAR); #endregion Save DAR sb.Clear(); sb.Append(resu.Select(x => x.LocationName).FirstOrDefault() + "."); } else if (count == 2) //--SELECT 2,0,0,'You are not authorised to delete this user' { sb.Clear(); sb.Append(resu.Select(x => x.LocationName).FirstOrDefault() + "."); } } else { sb.Clear(); sb.Append("Please provide proper details for execute delete operation."); } } catch (Exception ex) { throw ex; } Tuple <int, string> returnResult = new Tuple <int, string>(count, sb.ToString()); return(returnResult); }