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

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

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

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

            return(Ok());
        }
示例#15
0
 public void RegistraUsuario(OwnerUser owner)
 {
     _service.AddOwner(owner);
 }