public void Post([FromBody] OwnerViewModel owner)
        {
            Mapper.Initialize(cfg => cfg.CreateMap <OwnerViewModel, OwnerDto>());
            var ownersDto = Mapper.Map <OwnerViewModel, OwnerDto>(owner);

            ownerService.AddOwner(ownersDto);
        }
Ejemplo n.º 2
0
 public ActionResult <Owner> Post([FromBody] Owner owner)
 {
     owner.Id = 0;
     if (string.IsNullOrEmpty(owner.Address))
     {
         return(null);
     }
     return(_ownerServie.AddOwner(owner));
 }
Ejemplo n.º 3
0
        public async Task <IActionResult> Create(AddOwnerViewModel model)
        {
            if (ModelState.IsValid)
            {
                _ownerService.AddOwner(model, await GetActiveUserId());
                return(RedirectToAction("Index"));
            }

            return(View(model));
        }
Ejemplo n.º 4
0
 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));
        }
Ejemplo n.º 6
0
 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));
     }
 }
Ejemplo n.º 7
0
        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));
        }
Ejemplo n.º 8
0
        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));
        }
Ejemplo n.º 9
0
        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));
            }
        }
Ejemplo n.º 10
0
        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));
            }
        }
Ejemplo n.º 11
0
 public void Post([FromBody] Owner newOwner)
 {
     _OwnerService.AddOwner(newOwner);
 }
Ejemplo n.º 12
0
 // POST: api/Owner
 public void Post([FromBody] OwnerDTO owner)
 {
     _ownerService.AddOwner(owner);
 }
Ejemplo n.º 13
0
        public IActionResult AddNewOwner(NewOwnerVm model)
        {
            var id = _ownerService.AddOwner(model);

            return(RedirectToAction("Index", "Owner"));
        }
Ejemplo n.º 14
0
        public async Task <IActionResult> AddOwner(OwnerInformation ownerInformation)
        {
            await _service.AddOwner(ownerInformation);

            return(Ok());
        }
Ejemplo n.º 15
0
 public void RegistraUsuario(OwnerUser owner)
 {
     _service.AddOwner(owner);
 }