コード例 #1
0
 public bool Add(Product o)
 {
     try
     {
         o.AddTime      = DateTime.Now;
         o.ModifiedTime = DateTime.Now;
         _context.Products.Add(o);
         _context.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
コード例 #2
0
 public bool Add(Category o)
 {
     try
     {
         o.AddTime      = DateTime.Now;
         o.ModifiedTime = DateTime.Now;
         _context.Categories.Add(o);
         _context.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
コード例 #3
0
 public bool Add(Account o)
 {
     try
     {
         if (_context.Accounts.FirstOrDefault(k => k.Email.Equals(o.Email)) != null)
         {
             return(false);
         }
         o.AddTime        = DateTime.Now;
         o.ModifiedTime   = DateTime.Now;
         o.PasswordHashed = Protector.HashPassword(o.PasswordHashed);
         _context.Accounts.Add(o);
         _context.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }