public dynamic resetPassword(dynamic myParams) { // #region "Validations" if (myParams == null || myParams.email == "") { return(new jResponse()); } // Extract parameters string email = myParams.email; string password = ""; DateTime currentDT = genApiController.getDate(); // Get executive list using (CashCoopanEntities1 db = new CashCoopanEntities1()) { // Check for valid mobile number var dbExecutiveInfo = db.Users.Where(i => i.UserName == email && !i.IsDeleted).FirstOrDefault(); if (dbExecutiveInfo != null) { //password = currentDT.Second.ToString("00").Substring(0, 1) + dbExecutiveInfo.Mobile.Substring(5, 1) + dbExecutiveInfo.Mobile.Substring(1, 1) + currentDT.Millisecond.ToString("000").Substring(0, 1); //help_sendPassword(dbExecutiveInfo.Email, password); //dbExecutiveInfo.Password = password; //dbExecutiveInfo.UpdatedDT = currentDT; //db.Entry(dbExecutiveInfo).State = EntityState.Modified; //db.SaveChanges(); } else { return(new jResponse(true, "Please enter valid email address.", null)); } return(new jResponse(false, "Your new password has been sent to you by SMS.", null)); } }
// getDate() - Get current DT. public static DateTime getDate() { DateTime dt = new DateTime(); using (CashCoopanEntities1 db = new CashCoopanEntities1()) { dt = db.Database.SqlQuery <DateTime>("SELECT GETDATE()").FirstOrDefault <DateTime>(); } return(dt); }
public IEnumerable <tblTicketMaster> GetAllTickets(int userId) { using (CashCoopanEntities1 db = new CashCoopanEntities1()) { var objTickets = db.tblTicketMasters.ToList(); var objPendingTickets = db.tblUserTickets.Where(x => x.userId == userId).ToList().Select(x => x.ticketId).ToList(); objTickets = objTickets.Where(x => !objPendingTickets.Any(m => m.Value == x.ticketId)).ToList(); return(objTickets); } }
public bool SubmitCoopan(AddUserCoopanModel model) { using (CashCoopanEntities1 db = new CashCoopanEntities1()) { var isExits = db.tblUserTickets.Where(x => x.ticketId == model.TicketId && x.userId == model.UserId && x.status == (int?)CoopanStatus.Completed).FirstOrDefault(); if (isExits == null) { tblUserTicket dbModel = new tblUserTicket(); dbModel.ticketId = model.TicketId; dbModel.userId = model.UserId; dbModel.ticketDate = DateTime.UtcNow; dbModel.status = (int?)CoopanStatus.Completed; db.tblUserTickets.Add(dbModel); db.SaveChanges(); return(true); } return(false); } }
public dynamic login(dynamic myParams) { // #region "Validations" // Basic validations if (myParams == null || myParams.userName == "" || myParams.password == "") { return(new jResponse()); } // Extract parameters string userName = myParams.userName; string password = myParams.password; // #endregion // #region "Generate token" MemoryCache personToken = MemoryCache.Default; genApiController gen = new genApiController(); // Keep changing Guid until a unique one is found. // This is to ensure that Guid is not repeated. token retToken = new token(); retToken.tokenID = Guid.NewGuid().ToString(); while (personToken.Contains(retToken.tokenID)) { retToken.tokenID = Guid.NewGuid().ToString(); } retToken.canForward = false; retToken.canDispatchCreate = false; retToken.canUpdateStatus = false; retToken.canScheduled = false; retToken.canLoading = false; retToken.canDispatchView = false; retToken.canStart = false; retToken.canFinish = false; retToken.canFeedback = false; // #endregion // #region "Check for SuperAdmin" //string adminUserName = WebConfigurationManager.AppSettings["LoginID"]; //string adminPassword = WebConfigurationManager.AppSettings["Password"]; using (CashCoopanEntities1 db = new CashCoopanEntities1()) { var executiveInfo = (from dbe in db.Users where dbe.UserName == userName && dbe.Password == password && !dbe.IsDeleted select new { dbe }).FirstOrDefault(); if (executiveInfo != null) { //List<int> rightIDs = gen.splitString('~', executiveInfo.dbe.Rights).Where(x => !string.IsNullOrEmpty(x)).Select(int.Parse).ToList(); retToken.userID = executiveInfo.dbe.UserID; retToken.name = executiveInfo.dbe.FName + ' ' + executiveInfo.dbe.LName; //retToken.serviceRights = executiveInfo.dbe.ServiceRights; genApiController.setPersonTkn(retToken); } else { return(new jResponse(true, "Please enter valid credentials.", null)); } return(new jResponse(false, "Welcome, " + retToken.name + "!", retToken)); } // #endregion // #endregion }