コード例 #1
0
 public bool CreateUser(User user)
 {
     try
     {
         var entity = new User
         {
             Email    = user.Email,
             Name     = user.Name,
             Phone    = user.Phone,
             Pass     = user.Pass,
             DOB      = user.DOB,
             Sex      = user.Sex,
             RoleID   = user.RoleID,
             StatusID = user.StatusID,
             Address  = user.Address,
             RegDate  = System.DateTime.Now,
             Img_Link = user.Img_Link
         };
         db.Users.Add(entity);
         db.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
コード例 #2
0
ファイル: OrderDao.cs プロジェクト: nguyenduchoan9/AndroidApi
 public bool createOrder(String username, int userId, String note, String address, int bookId, double price)
 {
     try
     {
         var entity = new Order
         {
             UserName    = username,
             UserID      = userId,
             StartDate   = System.DateTime.Now,
             EndDate     = System.DateTime.Now,
             StatusID    = 1,
             Note        = note,
             Address     = address,
             CreatedDate = System.DateTime.Now,
         };
         var order = db.Orders.Add(entity);
         int ac    = db.SaveChanges();
         if (ac > 0)
         {
             OrderDetail od = new OrderDetail
             {
                 OrderID  = order.ID,
                 BookID   = bookId,
                 Quantity = 1,
                 Price    = price
             };
             db.OrderDetails.Add(od);
             int rs = db.SaveChanges();
             if (rs > 0)
             {
                 return(true);
             }
             return(false);
         }
         return(false);
     }
     catch
     {
         return(false);
     }
 }