public async Task<int> Save(T_Customer_Task model) { using (db = new KBLDataContext()) { var entity = await (from t in db.CustomerTasks where t.TaskId == model.TaskId select t).FirstOrDefaultAsync(); if (entity == null) { entity = await (from t in db.CustomerTasks where t.CId == model.CId orderby t.StartDate descending select t).FirstOrDefaultAsync(); if (entity != null) { model.Describe = entity.Describe; model.Other = entity.Other; model.During = (model.StartDate - entity.StartDate).Value.Days + ""; model.Review = (model.StartDate - entity.StartDate).Value.Days + ""; } db.CustomerTasks.Add(model); } else { entity.StartDate = model.StartDate; entity.Describe = model.Describe; entity.Review = model.Review; entity.ReviewStatus = model.ReviewStatus; entity.During = model.During; entity.Other = model.Other; db.Entry(entity).State = EntityState.Modified; } return await db.SaveChangesAsync(); } }
public async Task<object> Save(T_JSON model) { object effects = 0; T_Customer_Task task = new T_Customer_Task(); if (model.Input0 != null) { string s = string.Empty; s = POSTJson.ResolveTJSON(model); task = JsonConvert.DeserializeObject<T_Customer_Task>(s); effects = await T_Customer_BLL.SaveCustomerTask(task); } return Ok(new { statusCode = 200, result = effects }); }
public static async Task<object> SaveCustomerTask(T_Customer_Task model) { using (T_Customer_Task_Entities entity = new T_Customer_Task_Entities()) { return await entity.Save(model); } }