Beispiel #1
0
        public IHttpActionResult UpdateCountry(CountryModel model)
        {
            var response = new DataResponse <EntityCountry>();

            if (ModelState.IsValid)
            {
                var entityCountry = new EntityCountry();
                entityCountry.Id          = model.Id;
                entityCountry.CountryName = model.CountryName;
                entityCountry.CountryCode = model.CountryCode;
                entityCountry.IsActive    = model.IsActive;
                entityCountry.UpdatedBy   = CurrentUserId;
                entityCountry.UpdatedOn   = System.DateTime.UtcNow;
                response = repository.UpdateCountry(entityCountry);
                return(Ok <DataResponse>(response));
            }
            else
            {
                var errorList = ModelState.Where(a => a.Value.Errors.Any()).Select(s => new
                {
                    Key     = s.Key.Split('.').Last(),
                    Message = s.Value.Errors[0].ErrorMessage
                });
                return(Ok <dynamic>(new { Status = HttpStatusCode.BadRequest, Model = errorList }));
            }
        }