public bool UpShigong(ShigongModel model) { Shigong pt = c.Shigong.FirstOrDefault(n => n.Id == model.Id); pt.Money = model.Money; pt.BiaoduanId = model.BiaoduanId; //pt.Code = model.Code; pt.PayDuixiang = model.PayDuixiang; pt.RegisterPeople = model.RegisterPeople; pt.Remarks = model.Remarks; pt.ShiyongTime = model.ShiyongTime; pt.ShiyongTime2 = model.ShiyongTime2; pt.Yongtu = model.Yongtu; pt.ShenhePeople = model.ShenhePeople; c.SaveChanges(); return(true); }
public bool AddShigong(ShigongModel model) { model.Id = Guid.NewGuid(); int code; try { code = c.Shigong.Max(w => w.Code); } catch (Exception) { code = 1; } model.Code = code + 1; Shigong pt = GetMapperDTO.SetModel <Shigong, ShigongModel>(model); c.Shigong.Add(pt); c.SaveChanges(); return(true); }
public bool DeShigong(Guid id) { List <ShigongEnclosure> li = c.ShigongEnclosure.Where(w => w.ShigongId == id).ToList(); for (int i = li.Count - 1; i >= 0; i--) { c.ShigongEnclosure.Remove(li.ElementAt(i)); } List <ShigongImages> lii = c.ShigongImages.Where(w => w.ShigongId == id).ToList(); for (int i = lii.Count - 1; i >= 0; i--) { c.ShigongImages.Remove(lii.ElementAt(i)); } Shigong pt = c.Shigong.FirstOrDefault(n => n.Id == id); c.Shigong.Remove(pt); c.SaveChanges(); return(true); }