public void update(DailyPart dailyPart) { using (var context = new ApplicationDataContext()) { try { //context.Entry(DailyPart).State = EntityState.Modified; //context.SaveChanges(); } catch (Exception ex) { throw new Exception("No se puede actualizar el registro", ex); } } }
public void save(DailyPart dailyPart) { using (var context = new ApplicationDataContext()) { try { //context.DailyParts.Add(dailyPart); //context.SaveChanges(); } catch (Exception ex) { throw new Exception("No se puede guardar el registro", ex); } } }
public JsonResult Add(DailyPart dailyPart) { using (var context = new ApplicationDataContext()) { if (ModelState.IsValid) { try { return(Json(dailyPart, JsonRequestBehavior.AllowGet)); } catch (Exception error) { return(Json(error.Message)); } } return(Json(dailyPart)); } //var errors = ModelState.Keys.Where(k => ModelState[k].Errors.Count > 0) //.Select(k => new { propertyName = k, errorMessage = ModelState[k].Errors[0].ErrorMessage }); //return Json(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); //return Json(ModelState.Values.SelectMany(v => v.Errors)); //var modelStateErrors = this.ModelState.Keys.SelectMany(key => this.ModelState[key].Errors); //var modelStateErrors = this.ModelState.Keys.Select(k => new { propertyName = k, errorMessage = ModelState[k].Errors }); }