示例#1
0
        public async Task <ActionResult> Create(Address address)
        {
            if (ModelState.IsValid)
            {
                var personnelId = UserPersonnelId;
                var personnel   = await _personnelBusinessService.RetrievePersonnel(personnelId);

                if (personnel == null)
                {
                    return(RedirectToAction("Login", "Account"));
                }
                var result = await _addressBusinessService.CreateAddress(personnel.Entity.PersonnelId, address);

                if (result.Succeeded)
                {
                    return(this.JsonNet(string.Empty));
                }
                foreach (var error in result.Errors)
                {
                    ModelState.AddModelError("", error);
                }
            }
            return(this.JsonNet(
                       ModelState.Values.Where(e => e.Errors.Count > 0)
                       .Select(e => e.Errors.Select(d => d.ErrorMessage).FirstOrDefault())
                       .Distinct()));
        }