public ActionResult <GuestDetail> CreateGuest(GuestCreate p) { var Guest = this.mapper.Map <Guest>(p); Guest = this.GuestRepository.Create(Guest); return(this.mapper.Map <GuestDetail>(Guest)); }
public IHttpActionResult Post(GuestCreate guest) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateGuestService(); if (!service.CreateGuest(guest)) { return(InternalServerError()); } return(Ok()); }
public ActionResult Create(GuestCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateGuestService(); if (service.CreateGuest(model)) { TempData["SaveResult"] = "Your Guest Was Created."; return(RedirectToAction("Index")); } ; return(View(model)); }
public bool CreateGuest(GuestCreate model) { var entity = new Guest() { OwnerId = _userId, FullName = model.FullName, Address = model.Address, PhoneNumber = model.PhoneNumber, IsAttending = model.IsAttending, EventId = model.EventId }; using (var ctx = new ApplicationDbContext()) { ctx.Guests.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult CreateGuest(GuestCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateGuestService(); if (service.CreateGuest(model)) { TempData["SaveResult"] = "Your guest has been created!"; return(RedirectToAction("Index")); } ; ModelState.AddModelError("", "The guest could not be created."); return(View(model)); }
public override bool CanExecute(object parameter) { switch (parameter.ToString()) { case "Rooms": return(true); case "Lessons": return(true); case "Details": return(true); case "CreateGuest": return(LoginViewModel.IsAuthorized && GuestCreate.IsGeldig() && ResidenceCreate.IsGeldig()); case "Delete": return(LoginViewModel.IsAuthorized); } return(true); }
// POST -- Create Guest public bool CreateGuest(GuestCreate model) { var entity = new Guest() { ServerId = _userId, FirstName = model.FirstName, LastName = model.LastName, ContactNumber = model.ContactNumber, FullAddress = model.FullAddress, Notes = model.Notes, FirstTime = true // May need to add a CreatedUtc here and to data and model }; using (var ctx = new ApplicationDbContext()) { ctx.Guests.Add(entity); return(ctx.SaveChanges() == 1); } }