public void Save(PhoneEditItem item) { item.GetValidationErrors().ThrowIfHasErrors(); var dbItem = new Phone(); if (item.Id != 0) { dbItem = Db.Phones.Single(x => x.Id == item.Id); } else { dbItem.DateCreate = DateTime.Now; Db.Phones.Add(dbItem); } dbItem.CompanyId = item.CompanyId; dbItem.Number = item.Number; dbItem.Remarks = item.Remarks; dbItem.DateModify = DateTime.Now; Db.SaveChanges(); this.App.Company.RefreshDateModify(dbItem.CompanyId); item.Id = dbItem.Id; }
public ActionResult EditPhone([FromBody] PhoneEditItem item) { Service.Phone.Save(item); return(Json(item)); }