public void Post([FromBody] OwnerViewModel owner) { Mapper.Initialize(cfg => cfg.CreateMap <OwnerViewModel, OwnerDto>()); var ownersDto = Mapper.Map <OwnerViewModel, OwnerDto>(owner); ownerService.AddOwner(ownersDto); }
public ActionResult <Owner> Post([FromBody] Owner owner) { owner.Id = 0; if (string.IsNullOrEmpty(owner.Address)) { return(null); } return(_ownerServie.AddOwner(owner)); }
public async Task <IActionResult> Create(AddOwnerViewModel model) { if (ModelState.IsValid) { _ownerService.AddOwner(model, await GetActiveUserId()); return(RedirectToAction("Index")); } return(View(model)); }
public ActionResult <ObjectResult> Post([FromBody] Owner owner) { try { return(Ok(_ownerService.AddOwner(owner))); } catch (NullReferenceException e) { return(BadRequest(e.Message)); } }
public async Task <IActionResult> Create([FromForm] OwnerModel owner) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } ; await _ownerService.AddOwner(owner); return(CreatedAtAction("GetOwner", new { id = owner.Id }, owner)); }
public ActionResult <Owner> AddOwner([FromBody] Owner owner) { try { return(Ok(_ownerService.AddOwner(owner))); } catch (InvalidDataException e) { return(BadRequest("Something went wrong with your request\n" + e.Message)); } catch (DataBaseException e) { return(StatusCode(500, e.Message)); } }
private Owner CreateNewOwner() { Owner owner = new Owner(); Console.WriteLine("Write owner first name"); owner.Firstname = Console.ReadLine(); Console.WriteLine(" write owner last name"); owner.LastName = Console.ReadLine(); Console.WriteLine(" write Address"); owner.Address = Console.ReadLine(); Console.WriteLine(" write your email"); owner.Email = Console.ReadLine(); Console.WriteLine(" write your phonenumber"); owner.PhoneNumber = AskQuestion("your number"); return(_ownerService.AddOwner(owner)); }
public Owner NewOwner() { Console.WriteLine("Enter firstname: "); var firstName = Console.ReadLine(); Console.WriteLine("Enter lastname: "); var lastName = Console.ReadLine(); Console.WriteLine("Enter Address: "); var address = Console.ReadLine(); Console.WriteLine("Enter phone number: "); var phoneNr = Console.ReadLine(); Console.WriteLine("Enter email: "); var email = Console.ReadLine(); return(oService.AddOwner(firstName, lastName, address, phoneNr, email)); }
public ActionResult <Owner> CreateOwner([FromBody] Owner owner) { try { Owner ownerToAdd = OwnerService.CreateOwner(owner.FirstName, owner.LastName, owner.Address, owner.PhoneNumber, owner.Email); Owner addedOwner = OwnerService.AddOwner(ownerToAdd); if (addedOwner == null) { return(StatusCode(500, "Error saving pet to Database")); } return(Created("", addedOwner)); } catch (ArgumentException ex) { return(BadRequest(ex.Message)); } }
public ActionResult <Pet> Post([FromBody] Pet newPet) { var owner = newPet.PreviousOwner; //no ID But a new Owner if (owner != null && owner.Id <= 0 && owner.FirstName != null && owner.LastName != null) { owner = _ownerService.AddOwner(owner); newPet.PreviousOwner = new Owner() { Id = owner.Id }; } try { return(Ok(_petService.SavePet(newPet))); } catch (ArgumentException ex) { return(NotFound(ex.Message)); } }
public void Post([FromBody] Owner newOwner) { _OwnerService.AddOwner(newOwner); }
// POST: api/Owner public void Post([FromBody] OwnerDTO owner) { _ownerService.AddOwner(owner); }
public IActionResult AddNewOwner(NewOwnerVm model) { var id = _ownerService.AddOwner(model); return(RedirectToAction("Index", "Owner")); }
public async Task <IActionResult> AddOwner(OwnerInformation ownerInformation) { await _service.AddOwner(ownerInformation); return(Ok()); }
public void RegistraUsuario(OwnerUser owner) { _service.AddOwner(owner); }