public async Task CreateComunication(Expenses expenses, ExpensesCategory expensesCategory) { var expCategory = new ExpCategory() { ExpensesId = expenses.Id, ExpensesCategoryId = expensesCategory.Id }; _context.ExpCategories.Add(expCategory); await _context.SaveChangesAsync(); }
public static void UpdateExpCategory(ExpCategory expCat) { try { using (MDashExpenseEntities ee = GetConnection()) { ExpCategory expc = ee.ExpCategories.Find(expCat.id); expc.Name = expCat.Name; expc.SortOrder = expCat.SortOrder; ee.Entry(expc).State = EntityState.Modified; ee.SaveChanges(); } } catch (Exception ex) { throw new Exception("UpdateExpCategory Failed", ex); } }
public static int AddExpCategory(ExpCategory expCat) { int ret = 0; try { using (MDashExpenseEntities ee = GetConnection()) { ee.ExpCategories.Add(expCat); ee.SaveChanges(); ret = expCat.id; } } catch (Exception ex) { throw new Exception("GetExpCategoryList Failed", ex); } return ret; }
void Add(HttpContext context) { context.Response.ContentType = "application/json; charset=utf-8"; string pid = context.Request["pid"]; string name = context.Request["name"]; string s = context.Request["s"]; try { ExpCategory obj = new ExpCategory { Id = new Guid() , Name = context.Server.UrlDecode(name) , ParentId = string.IsNullOrWhiteSpace(pid) ? null : (Guid?)new Guid(pid) , SpecialtyId = s }; RepositoryFactory<ExpCategoryRepository>.Get().Add(obj); //log AppLog.Write("添加试验报告分类 \"" + obj.Name + "\"" , AppLog.LogMessageType.Info , "id=" + obj.Id.ToString() , this.GetType()); context.Response.Write("{\"id\":\"" + obj.Id.ToString() + "\"}"); } catch (Exception ex) { AppLog.Write("添加试验报告分类 出错" , AppLog.LogMessageType.Error , "" , ex , this.GetType()); context.Response.Write("{\"msg\":\""+ex.Message+"\"}"); } }
public static void UpdateExpCategory (ExpCategory expCat) { ExpenseDataService.UpdateExpCategory(expCat); Refresh(); }
public static ExpCategory AddItem(ExpCategory expCat) { expCat.id = ExpenseDataService.AddExpCategory(expCat); Refresh(); return expCat; }