public bool Update(Goods goods) { var db = _context.Goods.FirstOrDefault(x => x.Id == goods.Id); if (db == null) { return(false); } // init db.Idx = goods.Idx; db.Name = goods.Name; db.GoodsCatId = goods.GoodsCatId; db.DimensionId = goods.DimensionId; db.Val = goods.Val; db.ValDelivered = goods.ValDelivered; db.Price = goods.Price; db.Weight = goods.Weight; db.Delivery = goods.Delivery; db.ImpPeriod = goods.ImpPeriod; db.ImpTime = goods.ImpTime; db.ProviderId = goods.ProviderId; _context.SaveChanges(); return(true); }
public void Create(string name) { _context.Clients.Add(new DAL.Models.Client() { Name = name }); _context.SaveChanges(); }
public void Create(string userName, string password) { _context.Operators.Add(new DAL.Models.Operator() { Name = userName, Pwd = password //Pwd = PasswordGenerator.GeneratePwd() }); _context.SaveChanges(); }
public bool Update(Provider provider) { // check exists and not deleted var db = _context.Providers.FirstOrDefault(x => x.Deleting == 0 && x.Id == provider.Id); if (db == null) { return(false); } db.Name = provider.Name; db.Address = provider.Address; db.Phone = provider.Phone; _context.SaveChanges(); return(true); }
public bool Rename(decimal id, string name) { var category = _context.GoodsCats.FirstOrDefault(x => x.Id == id); if (category == null) { return(false); } category.Name = name; _context.SaveChanges(); return(true); }
public bool Update(Dimension dimension) { // exists if (_context.Dimensions.Any(x => x.Name == dimension.Name)) { return(false); } var db = _context.Dimensions.FirstOrDefault(x => x.Id == dimension.Id); if (db == null) { return(false); } db.Name = dimension.Name; _context.SaveChanges(); return(true); }
public static string Add() { string n = string.Empty; try { using (var db = new OracleDBContext()) { //批量操作用AddRange HLT.Model.Entity.Test test = new Model.Entity.Test(); test.ID = "1"; test.Name = "hh"; db.Tests.Add(test); db.SaveChanges(); } } catch (Exception ex) { throw ex; } return("1"); }