public OperationStatus ActionCarPoolRequest(CarPoolAssociationCustomModel model) { OperationStatus status = OperationStatus.Error; DateTime PoolDate = Convert.ToDateTime(model.DDate); try { using (dbcontext = new CarPoolApplicationEntities()) { var updatePoolInfo = dbcontext.tblCarPoolMemberAssociations.FirstOrDefault(x => x.AssociationId == model.AssociationId); if (updatePoolInfo != null) { updatePoolInfo.IsApproved = model.IsApproved; updatePoolInfo.ModifiedBy = model.ModifiedBy; updatePoolInfo.ModifiedDate = DateTime.Now; dbcontext.SaveChanges(); status = OperationStatus.Update; } else { status = OperationStatus.Duplicate; } } } catch (Exception ex) { dbcontext.Dispose(); status = OperationStatus.Exception; throw ex; } return(status); }
public object SearchCarPoolApplication(CarPoolRegistrationCustomModel model) { List <CarPoolRegistrationCustomModel> CarPoolListModel = new List <CarPoolRegistrationCustomModel>(); DateTime SearchDate = Convert.ToDateTime(model.PoolDate); try { using (dbcontext = new CarPoolApplicationEntities()) { CarPoolListModel = dbcontext.tblCarPoolRegistrations.Where(x => x.IsDeleted == false && (x.PoolDate.Value.Year == SearchDate.Year && x.PoolDate.Value.Month == SearchDate.Month && x.PoolDate.Value.Day == SearchDate.Day) && (x.Source.ToLower().Trim().Contains(model.Source.ToLower().Trim()) || model.Source.Trim() == String.Empty || model.Source == null) && (x.Destination.ToLower().Trim().Contains(model.Destination.ToLower().Trim()) || model.Destination.Trim() == String.Empty || model.Destination == null) ).Select(x => new CarPoolRegistrationCustomModel { Id = x.Id, MemberId = x.MemberId, MemberName = x.tblMember != null ? x.tblMember.Name : "", MobileNo = x.tblMember != null ? x.tblMember.MobileNo : "", EmailId = x.tblMember != null ? x.tblMember.EmailId : "", Source = x.Source, Destination = x.Destination, PoolDate = x.PoolDate, Charges = x.Charges, Time = x.Time, SeatsAvailable = x.SeatsAvailable, IsActive = x.IsActive, IsDeleted = x.IsDeleted, CreatedBy = x.CreatedBy, CreatedDate = x.CreatedDate, ModifiedBy = x.ModifiedBy, ModifiedDate = x.ModifiedDate }).OrderByDescending(x => x.Id).ToList(); } } catch (Exception ex) { dbcontext.Dispose(); throw ex; } return(CarPoolListModel); //DateTime KMEndDate = objDailyKisanMarketReportModel.EndDate.Add(new TimeSpan(5, 30, 0)); //DailyKisanListDetailQ = DailyKisanListDetailQ.Where(x => // (x.SaleDate.Year >= KMStartDate.Year // && x.SaleDate.Month >= KMStartDate.Month // && x.SaleDate.Day >= KMStartDate.Day) // && (x.SaleDate.Year <= KMEndDate.Year // && x.SaleDate.Month <= KMEndDate.Month // && x.SaleDate.Day <= KMEndDate.Day) }
public OperationStatus ForgotPassword(ForgotPasswordCustomModel model) { OperationStatus status = OperationStatus.Error; try { using (dbcontext = new CarPoolApplicationEntities()) { var rs = dbcontext.tblApplicationUsers.FirstOrDefault(x => x.UserName == model.UserName); if (rs != null) { string from = "*****@*****.**"; //any valid GMail ID string to = Convert.ToString(rs.EmailId); //any valid GMail ID using (MailMessage mail = new MailMessage(from, to)) { mail.Subject = "Car Pool Management Forgot Password"; mail.Body = "Dear " + rs.Name + " <br><br>Please use this password to login: "******"<br><br>Thanks,<br>Team"; mail.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; smtp.Port = 587; smtp.UseDefaultCredentials = false; smtp.Credentials = new System.Net.NetworkCredential ("*****@*****.**", "shally123");// Enter seders User name and password smtp.EnableSsl = true; smtp.Send(mail); status = OperationStatus.Success; } } else { status = OperationStatus.Duplicate; } } } catch (Exception ex) { dbcontext.Dispose(); status = OperationStatus.Exception; throw ex; } return(status); }
public object MyCarPoolApplication(int MemberId) { List <CarPoolRegistrationCustomModel> CarPoolListModel = new List <CarPoolRegistrationCustomModel>(); try { using (dbcontext = new CarPoolApplicationEntities()) { CarPoolListModel = dbcontext.tblCarPoolRegistrations.Where(x => x.IsDeleted == false && (x.MemberId == MemberId) ).Select(x => new CarPoolRegistrationCustomModel { Id = x.Id, MemberId = x.MemberId, MemberName = x.tblMember != null ? x.tblMember.Name : "", MobileNo = x.tblMember != null ? x.tblMember.MobileNo : "", EmailId = x.tblMember != null ? x.tblMember.EmailId : "", Source = x.Source, Destination = x.Destination, PoolDate = x.PoolDate, Charges = x.Charges, Time = x.Time, SeatsAvailable = x.SeatsAvailable, IsActive = x.IsActive, IsDeleted = x.IsDeleted, CreatedBy = x.CreatedBy, CreatedDate = x.CreatedDate, ModifiedBy = x.ModifiedBy, ModifiedDate = x.ModifiedDate }).OrderByDescending(x => x.Id).ToList(); } } catch (Exception ex) { dbcontext.Dispose(); throw ex; } return(CarPoolListModel); }
public object ListMyCarPoolActionRequest(int Id, DateTime DDate, int Status) { List <CarPoolAssociationCustomModel> CarPoolListModel = new List <CarPoolAssociationCustomModel>(); DateTime PoolDate = Convert.ToDateTime(DDate); try { using (dbcontext = new CarPoolApplicationEntities()) { CarPoolListModel = dbcontext.tblCarPoolMemberAssociations.Where(x => x.IsDeleted == false && x.CarPoolId == Id && (x.IsApproved == Status || Status == 0) && ((x.DDate.Value.Year == PoolDate.Year && x.DDate.Value.Month == PoolDate.Month && x.DDate.Value.Day == PoolDate.Day) || PoolDate == null) ).Select(x => new CarPoolAssociationCustomModel { AssociationId = x.AssociationId, CarPoolId = x.CarPoolId, MemberId = x.MemberId, MemberName = x.tblMember != null ? x.tblMember.Name : "", DDate = x.DDate, Description = x.Description, IsApproved = x.IsApproved, IsActive = x.IsActive, IsDeleted = x.IsDeleted, CreatedBy = x.CreatedBy, CreatedDate = x.CreatedDate, ModifiedBy = x.ModifiedBy, ModifiedDate = x.ModifiedDate }).OrderByDescending(x => x.AssociationId).ToList(); } } catch (Exception ex) { dbcontext.Dispose(); throw ex; } return(CarPoolListModel); }
/// <summary> /// This method is used to save new pool info /// </summary> /// <returns></returns> public OperationStatus SaveCarPoolApplication(CarPoolRegistrationCustomModel model) { OperationStatus status = OperationStatus.Error; try { using (dbcontext = new CarPoolApplicationEntities()) { if (model.Id == 0) { tblCarPoolRegistration _addCarPool = new tblCarPoolRegistration { MemberId = model.MemberId, Source = model.Source, Destination = model.Destination, PoolDate = model.PoolDate, Time = model.Time, Charges = model.Charges, SeatsAvailable = model.SeatsAvailable, IsActive = true, IsDeleted = false, CreatedDate = DateTime.Now, CreatedBy = model.CreatedBy, ModifiedDate = DateTime.Now, ModifiedBy = model.ModifiedBy, }; dbcontext.tblCarPoolRegistrations.Add(_addCarPool); dbcontext.SaveChanges(); status = OperationStatus.Success; } else { var updatePoolInfo = dbcontext.tblCarPoolRegistrations.FirstOrDefault(m => m.Id == model.Id); if (updatePoolInfo != null) { updatePoolInfo.MemberId = model.MemberId; updatePoolInfo.Source = model.Source; updatePoolInfo.Destination = model.Destination; updatePoolInfo.PoolDate = model.PoolDate; updatePoolInfo.Time = model.Time; updatePoolInfo.Charges = model.Charges; updatePoolInfo.SeatsAvailable = model.SeatsAvailable; updatePoolInfo.ModifiedBy = model.ModifiedBy; updatePoolInfo.ModifiedDate = DateTime.Now; dbcontext.SaveChanges(); status = OperationStatus.Update; } } } } catch (Exception ex) { dbcontext.Dispose(); status = OperationStatus.Exception; throw ex; } return(status); }
public void Dispose() { dbcontext.Dispose(); GC.SuppressFinalize(this); //throw new NotImplementedException(); }
/// <summary> /// This method is used to save new members /// </summary> /// <returns></returns> public OperationStatus SaveApplicationUser(ApplicationUserModel applicationUserModel) { OperationStatus status = OperationStatus.Error; using (TransactionScope ts = new TransactionScope()) { try { using (dbcontext = new CarPoolApplicationEntities()) { if (applicationUserModel.ApplicationUserId == 0) { var rs = dbcontext.tblApplicationUsers.FirstOrDefault(x => x.UserName == applicationUserModel.UserName && x.IsDeleted == false); if (rs == null) { tblMember _addMember = new tblMember { Name = applicationUserModel.Name, EmailId = applicationUserModel.EmailId, MobileNo = applicationUserModel.MobileNo, Gender = applicationUserModel.Gender, DateOfBirth = applicationUserModel.DateOfBirth, Address = applicationUserModel.Address, FatherName = applicationUserModel.FatherName, MotherName = applicationUserModel.MotherName, IsActive = true, IsDeleted = false, CreatedDate = DateTime.Now, CreatedBy = applicationUserModel.CreatedBy, ModifiedDate = DateTime.Now, ModifyBy = applicationUserModel.ModifyBy, }; dbcontext.tblMembers.Add(_addMember); dbcontext.SaveChanges(); int userid = _addMember.MemberId; tblApplicationUser _applicationUserinfo = new tblApplicationUser { Name = applicationUserModel.Name, EmailId = applicationUserModel.EmailId, MobileNo = applicationUserModel.MobileNo, UserIdentityKey = userid, UserName = applicationUserModel.UserName, Password = applicationUserModel.Password, IsActive = true, IsDeleted = false, CreatedDate = DateTime.Now, CreatedBy = applicationUserModel.CreatedBy, ModifiedDate = DateTime.Now, ModifyBy = applicationUserModel.ModifyBy, }; dbcontext.tblApplicationUsers.Add(_applicationUserinfo); dbcontext.SaveChanges(); status = OperationStatus.Success; ts.Complete(); } else { status = OperationStatus.Duplicate; //ts.Dispose(); } } } } catch (Exception ex) { dbcontext.Dispose(); status = OperationStatus.Exception; ts.Dispose(); throw ex; } } return(status); }
/// <summary> /// This method is used to save car pool requests /// </summary> /// <returns></returns> public OperationStatus SubmitCarPoolRequest(CarPoolAssociationCustomModel model) { OperationStatus status = OperationStatus.Error; DateTime PoolDate = Convert.ToDateTime(model.DDate); try { using (dbcontext = new CarPoolApplicationEntities()) { if (model.AssociationId == 0) { var rs = dbcontext.tblCarPoolMemberAssociations.FirstOrDefault(x => x.MemberId == model.MemberId && x.CarPoolId == model.CarPoolId && (x.DDate.Value.Year == PoolDate.Year && x.DDate.Value.Month == PoolDate.Month && x.DDate.Value.Day == PoolDate.Day) ); if (rs == null) { tblCarPoolMemberAssociation _addCarPool = new tblCarPoolMemberAssociation { MemberId = model.MemberId, CarPoolId = model.CarPoolId, DDate = PoolDate, Description = model.Description, IsApproved = 1, IsActive = true, IsDeleted = false, CreatedDate = DateTime.Now, CreatedBy = model.CreatedBy, ModifiedDate = DateTime.Now, ModifiedBy = model.ModifiedBy, }; dbcontext.tblCarPoolMemberAssociations.Add(_addCarPool); dbcontext.SaveChanges(); status = OperationStatus.Success; } else { status = OperationStatus.Duplicate; } } else { var rs = dbcontext.tblCarPoolMemberAssociations.FirstOrDefault(m => m.IsDeleted == false && m.MemberId == model.MemberId && m.CarPoolId == model.CarPoolId && (m.DDate.Value.Year == PoolDate.Year && m.DDate.Value.Month == PoolDate.Month && m.DDate.Value.Day == PoolDate.Day) && m.AssociationId != model.AssociationId ); if (rs == null) { var updatePoolInfo = dbcontext.tblCarPoolMemberAssociations.FirstOrDefault(x => x.AssociationId == model.AssociationId); if (updatePoolInfo != null) { updatePoolInfo.MemberId = model.MemberId; updatePoolInfo.CarPoolId = model.CarPoolId; updatePoolInfo.DDate = PoolDate; updatePoolInfo.Description = model.Description; updatePoolInfo.ModifiedBy = model.ModifiedBy; updatePoolInfo.ModifiedDate = DateTime.Now; dbcontext.SaveChanges(); status = OperationStatus.Update; } } else { status = OperationStatus.Duplicate; } } } } catch (Exception ex) { dbcontext.Dispose(); status = OperationStatus.Exception; throw ex; } return(status); }