public bool Add() { if (this.Valid()) { this.Id = General.UniqueString(this.Id); this.AddDate = DateTime.Now; using (WMContext context = new WMContext()) { UserReceipts model = new UserReceipts { Id = this.Id, UserId = this.UserId, ProvinceId = this.ProvinceId, CityId = this.CityId, AreaId = this.AreaId, Address = this.Address, Contact = this.Contact, Phone = this.Phone, ZipCode = this.ZipCode, AddDate = this.AddDate }; context.UserReceipts.Add(model); context.SaveChanges(); } return(true); } return(false); }
public bool Update() { if (this.Valid(true)) { using (WMContext context = new WMContext()) { UserReceipts model = context.UserReceipts.Find(this.Id); if (model != null) { model.ProvinceId = this.ProvinceId; model.CityId = this.CityId; model.AreaId = this.AreaId; model.Address = this.Address; model.Contact = this.Contact; model.Phone = this.Phone; model.ZipCode = this.ZipCode; context.SaveChanges(); return(true); } } } return(false); }
public static bool Delete(string id) { if (!General.IsNullable(id)) { using (WMContext context = new WMContext()) { UserReceipts model = context.UserReceipts.Find(id); if (model != null) { context.UserReceipts.Remove(model); context.SaveChanges(); return(true); } } } return(false); }
public bool Add() { if (this.Valid()) { this.Id = General.UniqueString(this.Id); this.AddDate = DateTime.Now; using (WMContext context = new WMContext()) { UserReceipts model = new UserReceipts { Id = this.Id, UserId = this.UserId, ProvinceId = this.ProvinceId, CityId = this.CityId, AreaId = this.AreaId, Address = this.Address, Contact = this.Contact, Phone = this.Phone, ZipCode = this.ZipCode, AddDate = this.AddDate }; context.UserReceipts.Add(model); context.SaveChanges(); } return true; } return false; }