Beispiel #1
0
        public async Task <ActionResult> Create(PolicyDtoCreate newPolicy)
        {
            if (ModelState.IsValid)
            {
                var result = await _client.PutAsync("api/PolicyAPI"
                                                    , Serializer.ToStringContent(newPolicy));

                if (result.IsSuccessStatusCode)
                {
                    return(RedirectToAction("Index"));
                }
            }
            return(View(newPolicy));
        }
Beispiel #2
0
        public async Task <IHttpActionResult> PutNewPolicy(PolicyDtoCreate newPolicy)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            try
            {
                var newEntity = MapperBuilder.Build(ConfigType.Out)
                                .Map <Policy>(newPolicy);
                var num = await _policyService.AddAsync(newEntity);

                return(Ok(newEntity.PolicyNumber));
            }
            catch (Exception)
            {
                return(BadRequest());
            }
        }