public ActionResult GetUserAccountDetails(int accountId = 0) { var model = new UserAccountDetails(); model.AccountDetails = _dataAccessLayer.GetAccountDetails(accountId); model.ListOfTransactions = _dataAccessLayer.GetAccountTransactions(accountId); return(View("UserAccountDetails", model)); }
public ActionResult Booking(BookingViewModel bookingViewModel) { DateTime week = DateTime.Now.Date.AddDays(7); var todaydate = DateTime.UtcNow.Date; List <Booking> bookingList = new List <Booking>(); string UserID = User.Identity.GetUserId(); var db = GetDb(); if (ModelState.IsValid) { var UserAccountDetail = db.UserAccountDetail.Where(x => x.UserId == UserID && x.BookingID == bookingViewModel.BookingID).FirstOrDefault(); if (UserAccountDetail == null) { PayPalbusinessLogic obj = new PayPalbusinessLogic(); String Token = obj.GetPaypalToken(); bookingViewModel.UserID = UserID; var Response = obj.SaveinfoinPaypalValut(Token, bookingViewModel); if (Response.state == "ok") { var booking = db.Booking.Where(x => x.ID == bookingViewModel.BookingID).FirstOrDefault(); UserAccountDetails UserAccountDetails = new UserAccountDetails(); UserAccountDetails.UserId = UserID; UserAccountDetails.BookingHour = bookingViewModel.BookingHour.ToString(); UserAccountDetails.CraditcardID = Response.id; UserAccountDetails.BookingID = bookingViewModel.BookingID; UserAccountDetails.FirstName = bookingViewModel.FirstName; UserAccountDetails.LastName = bookingViewModel.LastName; UserAccountDetails.Createddate = DateTime.Now; UserAccountDetails.PhoneNumber = bookingViewModel.PhoneNumber; UserAccountDetails.CVV = bookingViewModel.cvv.ToString(); UserAccountDetails.Email = bookingViewModel.Email; UserAccountDetails.UpdatedDate = DateTime.Now; UserAccountDetails.SessionComplete = false; db.UserAccountDetail.Add(UserAccountDetails); int recordsinserted = db.SaveChanges(); String Path = System.Web.HttpContext.Current.Server.MapPath(@"~/App_Data/Template/emailtemplate.html"); EmailSender.SendEmail(bookingViewModel.FirstName, bookingViewModel.Email, bookingViewModel.FirstName, Path, booking.ZoomURL, booking.UTCStartTime.ToString(), booking.UTCEndTime.ToString()); ViewBag.Success = "Session Booked Succesfully."; } } else { ViewBag.ErrMessage = "You have already booking this Sessions."; bookingList = db.Booking.ToList(); bookingViewModel.ThreeHourWebiner = bookingList.Where(z => z.UTCStartTime.Date >= todaydate && z.UTCStartTime.Date <= week && z.SessionType == 1 && z.UserId == "67cb4926-6397-42b8-8bc5-ec85dd3ce2a7").ToList(); bookingViewModel.OneHourWebiner = bookingList.Where(z => z.UTCStartTime.Date >= todaydate && z.UTCStartTime.Date <= week && z.SessionType == 2 && z.UserId == "67cb4926-6397-42b8-8bc5-ec85dd3ce2a7").ToList(); bookingViewModel.TenMinuteWebiner = bookingList.Where(z => z.UTCStartTime.Date >= todaydate && z.UTCStartTime.Date <= week && z.SessionType == 3 && z.UserId == "67cb4926-6397-42b8-8bc5-ec85dd3ce2a7").ToList(); return(View(bookingViewModel)); } } bookingList = db.Booking.ToList(); bookingViewModel.ThreeHourWebiner = bookingList.Where(z => z.UTCStartTime.Date >= todaydate && z.UTCStartTime.Date <= week && z.SessionType == 1 && z.UserId == "67cb4926-6397-42b8-8bc5-ec85dd3ce2a7").ToList(); bookingViewModel.OneHourWebiner = bookingList.Where(z => z.UTCStartTime.Date >= todaydate && z.UTCStartTime.Date <= week && z.SessionType == 2 && z.UserId == "67cb4926-6397-42b8-8bc5-ec85dd3ce2a7").ToList(); bookingViewModel.TenMinuteWebiner = bookingList.Where(z => z.UTCStartTime.Date >= todaydate && z.UTCStartTime.Date <= week && z.SessionType == 3 && z.UserId == "67cb4926-6397-42b8-8bc5-ec85dd3ce2a7").ToList(); return(View(bookingViewModel)); }
public ActionResult EditAccount(UserAccountDetails model, string submitButton, FormCollection formColl) { //check the other submit buttons and act on them, or continue switch (submitButton) { case "Terminate": case "Activate": case "Unlock": return(RedirectToAction("Index", "Alarms")); } // Rebind model since locale of thread has been set since original binding of model by MVC if (TryUpdateModel(model, formColl.ToValueProvider())) { UpdateModel(model, formColl.ToValueProvider()); } // Revalidate model after rebind. ModelState.Clear(); TryValidateModel(model); //default is save if (ModelState.IsValid) { //make sure that email doesnt exist in the system already. (expect for the current user). otherwise show an error. var emailAlreadyExists = (new DiscountFactory(Session[Constants.Security.ConnectionStringSessionVariableName].ToString())).CheckExistingEmail(model.UserId, model.Email, model.CustomerId); if (emailAlreadyExists) { ModelState.AddModelError("Email", (new ResourceFactory()).GetLocalizedTitle(ResourceTypes.ErrorMessage, "That email is already in use.")); return(View(model)); } (new DiscountFactory(Session[Constants.Security.ConnectionStringSessionVariableName].ToString())).SaveUserAcount(model); ModelState.Clear(); ModelState.AddModelError(Constants.ViewData.ModelStateStatusKey, (new ResourceFactory()).GetLocalizedTitle(ResourceTypes.StatusMessage, "Account Saved")); return(EditAccount(model.UserId)); //return RedirectToAction("EditAccount", "Discounts", new {userId = model.UserId}); } return(View(model)); }
/// <summary> /// Maps an EF user record from the db into a UserAccountDetails object. If the /// db record is null then null is returned. /// </summary> /// <param name="dbUser">User record from the database.</param> public virtual UserAccountDetails Map(User dbUser) { if (dbUser == null) { return(null); } var user = new UserAccountDetails() { Email = dbUser.Email, FirstName = dbUser.FirstName, LastName = dbUser.LastName, UserId = dbUser.UserId, Username = dbUser.Username, LastLoginDate = DbDateTimeMapper.AsUtc(dbUser.LastLoginDate), LastPasswordChangeDate = DbDateTimeMapper.AsUtc(dbUser.LastPasswordChangeDate), PreviousLoginDate = DbDateTimeMapper.AsUtc(dbUser.PreviousLoginDate), RequirePasswordChange = dbUser.RequirePasswordChange }; user.AuditData = new CreateAuditData() { CreateDate = DbDateTimeMapper.AsUtc(dbUser.CreateDate) }; if (dbUser.Creator != null) { user.AuditData.Creator = _userMicroSummaryMapper.Map(dbUser.Creator); } var userArea = _userAreaRepository.GetByCode(dbUser.UserAreaCode); EntityNotFoundException.ThrowIfNull(userArea, dbUser.UserAreaCode); user.UserArea = new UserAreaMicroSummary() { UserAreaCode = dbUser.UserAreaCode, Name = userArea.Name }; return(user); }
/// <summary> /// Saves a discount scheme user account /// </summary> public void SaveUserAcount(UserAccountDetails userAccountDetails) { //ge the user acount var user = PemsEntities.Users.FirstOrDefault(x => x.UserID == userAccountDetails.UserId); if (user != null) { //only able to edit certain fields, so those are the ones we are saving. //email,phone, add 1 2, city, state, postal user.UserEmail = userAccountDetails.Email; user.PhoneNumber = userAccountDetails.Phone; user.UserAddress = userAccountDetails.Address1; user.Address2 = userAccountDetails.Address2; user.City = userAccountDetails.City; user.AddressState = userAccountDetails.State; user.PostalCode = userAccountDetails.PostalCode; PemsEntities.SaveChanges(); } }
public async Task <AccountFeedback> SetAccountDetails([FromBody] UserAccountDetails details) { if (ModelState.IsValid == false) { return(null); } var user = await _users.GetUser(details.UserId, detectChanges : true); if (user == null) { return(null); } user.GenderId = (byte)details.GenderId; user.Motto = details.Motto; _users.SaveChanges(); return(new AccountFeedback() { Result = FeedResult.Success }); }
public async Task <UserAccountDetails> GetAccountDetails(int userId) { if (userId <= 0) { return(null); } var user = await _users.GetBgcUser(userId); if (user == null) { return(new UserAccountDetails()); } var details = new UserAccountDetails() { Alive = true, GenderId = user.GenderId, Motto = user.Motto }; return(details); }
/// <summary> /// Gets a user account for a discount scheme user /// </summary> public UserAccountDetails GetUserAcount(int userID) { //ge the user acount var userAccount = new UserAccountDetails { DiscountSchemes = new List <UserDiscountScheme>() }; var user = PemsEntities.Users.FirstOrDefault(x => x.UserID == userID); if (user != null) { userAccount.CustomerId = user.DefaultCustomerID; userAccount.AccountExpirationDate = user.ExpirationDate; userAccount.AccountStatus = user.AccountStatu.AccountStatusDesc; userAccount.AccountStatusId = user.AccountStatu.AccountStatusId; userAccount.AccountStatusChangeTime = user.AccountStatusUpdated; userAccount.Address1 = user.UserAddress; userAccount.Address2 = user.Address2; userAccount.City = user.City; userAccount.CreationDate = user.Created; userAccount.Email = user.UserEmail; userAccount.FirstName = user.UserFName; //now the teh RBAC user that last modified this. if (user.LastEditedUserId.HasValue) { userAccount.LastEditiedByUserId = user.LastEditedUserId.Value; userAccount.LastEditiedByUserName = (new UserFactory()).GetUsername(user.LastEditedUserId.Value); } userAccount.LastName = user.UserLName; userAccount.LastUserAccess = user.LastUsed; userAccount.Notes = user.UserNote; userAccount.Phone = user.PhoneNumber; userAccount.PostalCode = user.PostalCode; userAccount.SecurityAnswer1 = user.SecurityAnswer1; userAccount.SecurityAnswer2 = user.SecurityAnswer2; userAccount.SecurityQuestion1 = user.SecurityQuestion1; userAccount.SecurityQuestion2 = user.SecurityQuestion2; userAccount.State = user.AddressState; userAccount.UserId = user.UserID; //CC info var card = user.DiscountUserCards.OrderByDescending(x => x.RegisteredTS).FirstOrDefault(); if (card != null) { userAccount.CreditCardExpirationDate = card.CardExpiry; userAccount.CreditCardLast4Digits = card.CardNumLast4; //now get the most recent transaction base don this cards Hash value var hash = card.PANHash; //not get all transactiosn from the TransactionsCreditCard table that matches this hash. var mostrecentTransaction = PemsEntities.TransactionsCreditCards.OrderByDescending(x => x.TransDateTime).FirstOrDefault(x => x.CardNumHash == hash); if (mostrecentTransaction != null) { userAccount.LastDiscountUsedTime = mostrecentTransaction.TransDateTime; //get the name of the scheme here if (mostrecentTransaction.DiscountScheme != null) { userAccount.LastDiscountUsedName = mostrecentTransaction.DiscountScheme.SchemeName; } } } //now that we have user info filled out, lets get the Discount schemes for this user if (user.DiscountUserSchemes.Any()) { foreach (var scheme in user.DiscountUserSchemes) { var userScheme = new UserDiscountScheme(); userScheme.ApplicationDate = scheme.CreatedTS; userScheme.SchemeName = scheme.DiscountScheme.SchemeName; userScheme.ApplicationStatus = scheme.DiscountSchemeStatu == null ? "" : scheme.DiscountSchemeStatu.DiscountSchemeStatusDesc; userScheme.ApplicationStatusDate = scheme.SchemeStatusDate; userScheme.ApplicationStatusNote = scheme.StatusNote; userScheme.ExpirationDate = scheme.ExpiryTS; userScheme.ApplicationStatusId = scheme.DiscountSchemeStatu == null ? 0 : scheme.DiscountSchemeStatu.DiscountSchemeStatusId; userScheme.DiscountUserSchemeId = scheme.DiscountUserSchemeId; //now the teh RBAC user that last modified this. if (scheme.ModifiedByUserId.HasValue) { userScheme.LastEditiedByUserId = scheme.ModifiedByUserId.Value; userScheme.LastEditiedByUserName = (new UserFactory()).GetUsername(scheme.ModifiedByUserId.Value); } userAccount.DiscountSchemes.Add(userScheme); } } } return(userAccount); }