Esempio n. 1
0
		public async Task<ActionResult> My()
		{
			var email = User.Identity.Name;

			var attendeeTask = AppFactory.AttendeeService.Value.GetAttendeeByEmailAsync(email);
			var ticketTask = AppFactory.TicketService.Value.GetTicketByEmailAsync(email);

			await Task.WhenAll(attendeeTask, ticketTask);

			var attendee = attendeeTask.Result;
			var ticket = ticketTask.Result;

			var model = new MyProfileModel
			{
				Email = attendee.EMail,
				LastName = attendee.LastName,
				FirstName = attendee.FirstName,
				Company = attendee.Company
			};

			model.Tickets = new List<TicketModel>();

			if (ticket == null)
			{
				if (DateTime.UtcNow.Month <= 5 && DateTime.UtcNow.Day <= 31 && DateTime.UtcNow.Year == 2016)
				{
					model.Tickets.Add(new TicketModel
					{
						TicketType = TicketType.EarlyBird,
						TicketName = "Ранняя регистрация",
						TicketNotes = ""
					});
				}
				else
				{
					model.Tickets.Add(new TicketModel
					{
						TicketType = TicketType.Regular,
						TicketName = "Стандартный",
						TicketNotes = ""
					});
				}
				model.Tickets.Add(new TicketModel
				{
					TicketType = TicketType.Educational,
					TicketName = "Студенческий",
					TicketNotes = "Для получения бейджа необходимо предъявить действующий студенческий билет в момент регистрации на конференцию."
				});
			}
			else
			{
				model.PayedTicket = ticket;
			}

			return View(model);
		}
Esempio n. 2
0
		public async Task<ActionResult> My(MyProfileModel model)
		{
			var email = User.Identity.Name;
			var attendee = await AppFactory.AttendeeService.Value.GetAttendeeByEmailAsync(email);

			attendee.EMail = email;
			attendee.LastName = model.LastName;
			attendee.FirstName = model.FirstName;
			attendee.Company = model.Company;

			if (!string.IsNullOrEmpty(model.Password))
			{
				var salt = AppFactory.AttendeeService.Value.GenerateSalt();
				var passwordHash = AppFactory.AttendeeService.Value.Hash(model.Password, salt);

				attendee.Salt = salt;
				attendee.PasswordHash = passwordHash;
			}

			await AppFactory.AttendeeService.Value.UpdateProfileAsync(attendee);

			return RedirectToAction("My");
		}