Example #1
0
        public IActionResult Post(string values)
        {
            var partner = new Partner();

            JsonConvert.PopulateObject(values, partner);

            if (!TryValidateModel(partner))
            {
                return(BadRequest(GetFullErrorMessage(ModelState)));
            }

            // Adding partner
            _partnerRepo.Add(partner);

            // Adding services
            var partnerVM = new PartnerVM();

            JsonConvert.PopulateObject(values, partnerVM);

            _partnerRepo.AddServices(partner.Id, partnerVM.Services);

            // Adding logo
            if (!String.IsNullOrEmpty(partner.Logo))
            {
                this.CreateLogoFromTempFile(partner);
            }

            return(_uow.Commit() ? Ok() : StatusCode(StatusCodes.Status500InternalServerError));
        }