コード例 #1
0
        public HttpResponseMessage Post(CoupleDTO coupleDto)
        {
            var personPartner = new PersonBusiness()
            {
                FirstName = coupleDto.FirstNamePartner,
                LastName  = coupleDto.LastNamePartner,
                CI        = coupleDto.IdPartner,
                Telephone = coupleDto.TelephonePartner,
                Direction = coupleDto.AddressPartner,
                Mail      = coupleDto.MailPartner
            };
            var person = new PersonBusiness()
            {
                FirstName = coupleDto.FirstName,
                LastName  = coupleDto.LastName,
                CI        = coupleDto.Id,
                Telephone = coupleDto.Telephone,
                Direction = coupleDto.Address,
                Mail      = coupleDto.Mail
            };

            var presentList = new PresentListBusiness()
            {
                Quantity = 25
            };

            int IDPersonPartner = _personService.AddPerson(personPartner);
            int IDPerson        = _personService.AddPerson(person);
            int IDPresentList   = _presentListService.Add(presentList);


            var couple = new CoupleBusiness()
            {
                WeddingDate   = coupleDto.WeddingDate,
                DeliveryDate  = coupleDto.DeliveryDate,
                Address       = coupleDto.AddressDelivery,
                HusbandID     = IDPersonPartner,
                WifeID        = IDPerson,
                PresentListID = IDPresentList,
                Latitude      = coupleDto.Latitude,
                Longitude     = coupleDto.Longitude
            };

            int IDCouple = _coupleService.AddCouple(couple);

            var account = new AccountBusiness(person, personPartner, IDCouple);

            _accountService.AddAccount(account);

            AccountDTO accountDTO = new AccountDTO()
            {
                Account          = account.Name,
                Password         = account.Password,
                FirstName        = person.FirstName,
                FirstNamePartner = personPartner.FirstName
            };

            return(Request.CreateResponse(HttpStatusCode.OK, accountDTO));
        }
コード例 #2
0
 public IActionResult Post([FromBody] PersonDto person)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest("Data are not valid!"));
     }
     _personsService.AddPerson(person);
     return(Ok("New element inserted successfully"));
 }
コード例 #3
0
        public IActionResult AddPerson(EntityModels.Person person)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var addedPerson = _personService.AddPerson(person);

            return(Created($"/api/v1/persons/{addedPerson.PersonId}", addedPerson));
        }
コード例 #4
0
 public ActionResult AddPerson(PersonModel model)
 {
     if (!ModelState.IsValid)
     {
         return(View(model));
     }
     else
     {
         _personsService.AddPerson(model);
         return(RedirectToAction("List", "Person"));
     }
 }