public static async Task<object> SaveCustomer(T_Customer model) { using (T_Customer_Entities entity = new T_Customer_Entities()) { return await entity.Save(model); } }
public async Task<object> GetCustomer(T_Customer model) { object o = await T_Customer_BLL.GetCustomer(model.Cid); return Ok(new { statusCode = 200, result = o }); }
public async Task<object> Register(T_JSON model) { T_Customer customer = new T_Customer(); object effects = 0; if (model.Input0 != null) { string s = string.Empty; s = POSTJson.ResolveTJSON(model); customer = JsonConvert.DeserializeObject<T_Customer>(s); effects = await T_Customer_BLL.SaveCustomer(customer); } return Ok(new { statusCode = 200, result = effects }); }
public async Task<object> Save(T_Customer model) { var cname = model.CName; var contact = model.Contact; using (db = new KBLDataContext()) { var exist = await (from c in db.Customers where c.Cid == model.Cid select c).FirstOrDefaultAsync(); if (exist == null) { db.Customers.Add(model); int effects = await db.SaveChangesAsync(); return new { effects = effects, model = model }; } else { //UpdateModel(); exist.Dietitian = model.Dietitian; exist.CName = model.CName; exist.CustomerNo = model.CustomerNo; exist.Age = model.Age; exist.CategoryID = model.CategoryID; exist.Addr = model.Addr; exist.Weight = model.Weight; exist.Height = model.Height; exist.Gender = model.Gender; exist.Contact = model.Contact; exist.CardType = model.CardType; exist.Married = model.Married; exist.Address = model.Address; exist.Remark = model.Remark; db.Entry(exist).State = EntityState.Modified; int effects = await db.SaveChangesAsync(); return new { effects = effects }; } } }