private void setupCustomerData()
        {
            string fileContent;

            fileContent = System.IO.File.ReadAllText("sample-data/Customers.json");
            IEnumerable <Customer> customers = JsonSerializer.Deserialize <IEnumerable <Customer> >(fileContent);

            _context.Customers.AddRange(customers);
            _context.SaveChanges();
        }
Exemple #2
0
        public bool PostCategory(Category category)
        {
            try
            {
                using (var db = new OrderManagementDbContext(_configuration))
                {
                    db.Categories.Add(category);
                    db.SaveChanges();

                    return(true);
                }
            }
            catch
            {
                return(false);
            }
        }
Exemple #3
0
        public bool PostItem(Item item)
        {
            try
            {
                using (var db = new OrderManagementDbContext(_configuration))
                {
                    db.Items.Add(item);
                    db.SaveChanges();

                    return(true);
                }
            }
            catch
            {
                return(false);
            }
        }
Exemple #4
0
        public async Task <string> InsertCustomerReport(List <CustomerReport> requestViewModel)
        {
            _orderManagementDbContext.Database.BeginTransaction();
            try
            {
                await _orderManagementDbContext.CustomerReport.AddRangeAsync(requestViewModel);

                _orderManagementDbContext.SaveChanges();
                _orderManagementDbContext.Database.CurrentTransaction.Commit();

                return("Customer Added Successfully");
            }
            catch (Exception ex)
            {
                _orderManagementDbContext.Database.RollbackTransaction();
                throw ex;
            }
        }
Exemple #5
0
        public bool PostNotice(Notice notice)
        {
            try
            {
                using (var db = new OrderManagementDbContext(_configuration))
                {
                    notice.UserNo = db.Users.Single(u => u.UserID == notice.UserID).UserNo;

                    db.Notices.Add(notice);
                    db.SaveChanges();

                    return(true);
                }
            }
            catch
            {
                return(false);
            }
        }
Exemple #6
0
        public bool Signup(User user)
        {
            try
            {
                using (var db = new OrderManagementDbContext(_configuraton))
                {
                    user.Money      = 1000000;
                    user.SignUpDate = DateTime.Now;

                    db.Users.Add(user);
                    db.SaveChanges();

                    return(true);
                }
            }
            catch
            {
                return(false);
            }
        }
Exemple #7
0
        public bool PostReview(Review review)
        {
            try
            {
                using (var db = new OrderManagementDbContext(_configuration))
                {
                    review.UserNo = db.Users.Single(u => u.UserID == review.UserID).UserNo;

                    //나중에 Order 연동해서 해결해야 함.
                    //review.ItemName = db.Items.Single(c => c.ItemNo == review.ItemNo).ItemName;

                    db.Reviews.Add(review);
                    db.SaveChanges();

                    return(true);
                }
            }
            catch
            {
                return(false);
            }
        }
Exemple #8
0
 public int Save()
 {
     return(_dbContext.SaveChanges());
 }