Esempio n. 1
0
        public async Task <IActionResult> NewContactPartial(ContactNewViewModel model)
        {
            if (!Request.IsAjaxRequest())
            {
                return(RedirectToAction("BadRequest", "Home"));
            }

            if (model == null)
            {
                return(PartialView("_FailureToLoadDataPartial"));
            }

            ViewBag.HttpMethod = Request.Method;

            if (ModelState.IsValid)
            {
                var entity = model.GetBase();

                ServiceResultModel = await _contactService.AddNewContactEntityAsync(entity);

                if (ServiceResultModel.IsSuccess)
                {
                    return(PartialView("_SuccessAddPartial"));
                }
                else
                {
                    model.ErrorMessage = ServiceResultModel.ErrorMessage;
                }
            }

            return(PartialView("_NewContactPartial", model));
        }