Esempio n. 1
0
 public bool ValidateUser(UserDetails userDetails)
 {
     using (var db = new WatchCartDbContext())
     {
         if (!string.IsNullOrWhiteSpace(userDetails.Name))
         {
             var chkAlreadyExists = db.UserTable.Where(x => x.UserName == userDetails.Name).ToList();
             if (chkAlreadyExists.Count() > 0)
             {
                 return(true);
             }
         }
         else
         {
             throw new ArgumentNullException();
         }
     }
     return(false);
 }
Esempio n. 2
0
 public bool PlaceOrder(Watch watch)
 {
     if (watch.WatchDetails != "")
     {
         using (var db = new WatchCartDbContext())
         {
             if (watch != null)
             {
                 OrderDetailsTable orderDetails = new OrderDetailsTable();
                 orderDetails.CreatedDate  = DateTime.Now;
                 orderDetails.OrderDetails = watch.WatchDetails;
                 orderDetails.UserName     = watch.UserName;
                 db.OrderDetailsTable.Add(orderDetails);
                 db.SaveChanges();
                 return(true);
             }
         }
     }
     return(false);
 }
Esempio n. 3
0
 public bool CreateNewUser(UserDetails userDetails)
 {
     using (var db = new WatchCartDbContext())
     {
         if (!string.IsNullOrWhiteSpace(userDetails.Name))
         {
             var chkAlreadyExists = db.UserTable.Where(x => x.UserName == userDetails.Name).ToList();
             if (chkAlreadyExists.Count() > 0)
             {
                 return(false);
             }
             else
             {
                 UserTable userTable = new UserTable();
                 userTable.UserName = userDetails.Name;
                 db.UserTable.Add(userTable);
                 db.SaveChanges();
             }
         }
     }
     return(true);
 }
Esempio n. 4
0
        public List <Watch> GetWatchDetails(string UserName)
        {
            List <Watch> watches = new List <Watch>();

            if (!string.IsNullOrWhiteSpace(UserName))
            {
                using (var db = new WatchCartDbContext())
                {
                    var lst = db.OrderDetailsTable.Where(x => x.UserName == UserName).ToList();
                    if (lst != null && lst.Any())
                    {
                        foreach (var item in lst)
                        {
                            Watch watch = new Watch();
                            watch.CreatedTime  = item.CreatedDate;
                            watch.UserName     = item.UserName;
                            watch.WatchDetails = item.OrderDetails;
                            watches.Add(watch);
                        }
                    }
                }
            }
            return(watches);
        }