Exemplo n.º 1
0
        public async Task <bool> UpdateCustomerLastCheckOut(string id, CustomerItem model)
        {
            if (!ObjectId.TryParse(model.Id, out ObjectId objectId))
            {
                return(false);
            }

            var filter = Builders <Model.CustomerItem> .Filter.Eq("InternalId", objectId);

            var client = Collection().Find(filter).FirstOrDefaultAsync();

            if (client.Result == null)
            {
                return(false);
            }

            var objectUpdate = Builders <Model.CustomerItem> .Update
                               .Set(x => x.LoyaltyPoints, model.LoyaltyPoints)
                               .Set(x => x.LastCheckOut, model.LastCheckOut)
                               .Set(x => x.Update, DateTime.Now);

            await Collection().UpdateOneAsync(filter, objectUpdate);

            return(true);
        }
Exemplo n.º 2
0
        public ActionResult ChangePassword(string username, string currentpassword, string password, string repassword)
        {
            try
            {
                var customer = new CustomerItem();

                if (customerRepositoryFE.TryGetByUserNameAndPassword(out customer, username, currentpassword))
                {
                    customer.Password = password;

                    customerRepositoryFE.UpdateCustomer(customer);

                    return(Json(new
                    {
                        error = false,
                        message = "Thay đổi mật khẩu thành công"
                    }, JsonRequestBehavior.AllowGet));
                }

                return(Json(new
                {
                    error = false,
                    message = "Mật khẩu hiện tại không đúng"
                }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                Elmah.ErrorLog.GetDefault(null).Log(new Elmah.Error(ex));
            }

            return(Json(new
            {
                error = true
            }, JsonRequestBehavior.AllowGet));
        }
        public void Delete_Success()
        {
            // Arrange
            CustomerItem item = new CustomerItem()
            {
                Id   = "5c012842f8e2708cf041e247",
                Name = "Caisse_01"
            };
            Acknowledged deleteResult = new Acknowledged(1);

            _customerServicesMock.Setup(x => x.GetCustomer(item.Id)).Returns(Task.FromResult(item));
            _customerServicesMock.Setup(x => x.DeleteCustomer(item.Id))
            .ReturnsAsync(deleteResult)
            .Verifiable();
            _customerFlowValidMock
            .Setup(x => x.IsValidOperation(BaseValidatorType.Delete, It.IsAny <CustomerItem>(), null))
            .Returns(true)
            .Verifiable();

            // Act
            CustomerController controller   = new CustomerController(_customerServicesMock.Object, _customerFlowValidMock.Object);
            ActionResult       actionResult = controller.Delete(item.Id);

            // Assert.
            Assert.IsType <NoContentResult>(actionResult);
            NoContentResult actionResultType = actionResult as NoContentResult;

            Assert.Equal(actionResultType.StatusCode, (int)System.Net.HttpStatusCode.NoContent);
            _customerServicesMock.Verify();
            _customerFlowValidMock.Verify();
        }
Exemplo n.º 4
0
        public IHttpActionResult Get(string id,
                                     string lang,
                                     DateTime wed_date)
        {
            CustomerItem item = null;

            try
            {
                if (string.IsNullOrEmpty(id))
                {
                    item = new CustomerItem();
                }
                else
                {
                    item = db.FindItem(id, lang, wed_date);
                    if (item == null)
                    {
                        return(NotFound());
                    }
                }
            }
            catch (Exception ex)
            {
                while (ex.InnerException != null)
                {
                    ex = ex.InnerException;
                }
                throw ex;
            }

            return(Ok(item));
        }
        public void Put_Success()
        {
            // Arrange
            CustomerItem item = new CustomerItem()
            {
                Id   = "5c012842f8e2708cf041e247",
                Name = "Caisse_01"
            };

            _customerServicesMock.Setup(x => x.GetCustomer(item.Id)).Returns(Task.FromResult(item));
            _customerServicesMock.Setup(x => x.UpdateCustomer(item.Id, item))
            .ReturnsAsync(true)
            .Verifiable();
            _customerFlowValidMock
            .Setup(x => x.IsValidOperation(BaseValidatorType.Update, It.IsAny <CustomerItem>(), It.IsAny <CustomerItem>()))
            .Returns(true)
            .Verifiable();

            // Act
            CustomerController controller   = new CustomerController(_customerServicesMock.Object, _customerFlowValidMock.Object);
            ActionResult       actionResult = controller.Put(item);

            // Assert.
            Assert.IsType <AcceptedResult>(actionResult);
            AcceptedResult actionResultType = actionResult as AcceptedResult;

            Assert.Equal(actionResultType.StatusCode, (int)System.Net.HttpStatusCode.Accepted);
            _customerServicesMock.Verify();
            _customerFlowValidMock.Verify();
        }
        public void Get_All_Success()
        {
            // Arrange
            CustomerItem item = new CustomerItem()
            {
                Id   = "5c012842f8e2708cf041e247",
                Name = "Caisse_01"
            };
            IEnumerable <CustomerItem> items = new List <CustomerItem>()
            {
                item
            };

            _customerServicesMock.Setup(x => x.GetCustomerList()).Returns(Task.FromResult(items));

            // Act
            CustomerController controller   = new CustomerController(_customerServicesMock.Object, _customerFlowValidMock.Object);
            ActionResult       actionResult = controller.Get().Result;

            // Assert.
            Assert.IsType <OkObjectResult>(actionResult);
            OkObjectResult actionResultType = actionResult as OkObjectResult;

            Assert.Equal(actionResultType.StatusCode, (int)System.Net.HttpStatusCode.OK);
            Assert.Equal(((List <CustomerItem>)actionResultType.Value), ((List <CustomerItem>)items.ToList()));
        }
        public void Post_Success()
        {
            // Arrange
            CustomerItem item = new CustomerItem()
            {
                Id   = "",
                Name = "Caisse_01"
            };

            _customerServicesMock.Setup(x => x.AddCustomer(item))
            .Verifiable();
            _customerFlowValidMock
            .Setup(x => x.IsValidOperation(BaseValidatorType.Create, It.IsAny <CustomerItem>(), null))
            .Returns(true)
            .Verifiable();

            // Act
            CustomerController controller   = new CustomerController(_customerServicesMock.Object, _customerFlowValidMock.Object);
            ActionResult       actionResult = controller.Post(item);

            // Assert.
            Assert.IsType <CreatedResult>(actionResult);
            CreatedResult actionResultType = actionResult as CreatedResult;

            Assert.Equal(actionResultType.StatusCode, (int)System.Net.HttpStatusCode.Created);
            _customerServicesMock.Verify();
            _customerFlowValidMock.Verify();
        }
Exemplo n.º 8
0
        private void InitDataGridView()
        {
            this.dataGridViewEx1.ReadOnly = false;
            CustomerItem test1 = new CustomerItem()
            {
                Name = "湖南省长沙市", CardName = "湖南省长沙市", Status = "空闲", Count = 1, KeyWord = "在线客服", Source = "www.baidu.com", LastTime = DateTime.Parse("1984-04-04"), WaitTime = "10:10"
            };
            CustomerItem test2 = new CustomerItem()
            {
                Name = "福建省福州市", CardName = "福建省福州市", Status = "空闲", Count = 1, KeyWord = "在线客服", Source = "www.baidu.com", LastTime = DateTime.Parse("1985-05-05"), WaitTime = "11:11"
            };
            CustomerItem test3 = new CustomerItem()
            {
                Name = "北京市", CardName = "帅哥", Status = "空闲", Count = 1, KeyWord = "客服系统", Source = "www.baidu.com", LastTime = DateTime.Parse("1986-06-06"), WaitTime = "12:12"
            };
            CustomerItem test4 = new CustomerItem()
            {
                Name = "河北省", CardName = "王云鹏", Status = "已经来过", Count = 3, KeyWord = "", Source = "jobs.chinahr.com", LastTime = DateTime.Parse("1987-07-07"), WaitTime = "13:13"
            };
            CustomerItem test5 = new CustomerItem()
            {
                Name = "广东省汕尾市", CardName = "北大青鸟", Status = "正在对话", Count = 22, KeyWord = "网站客服", Source = "www.baidu.com", LastTime = DateTime.Parse("1988-08-08"), WaitTime = "14:14"
            };
            List <CustomerItem> lists = new List <CustomerItem>();

            lists.AddRange(new CustomerItem[] { test1, test2, test3, test4, test5 });
            this.dataGridViewEx1.DataSource      = new BindingList <CustomerItem>(lists);
            this.dataGridView1.DataSource        = new BindingList <CustomerItem>(lists);
            this.dataGridViewEx1.CellMouseClick += new DataGridViewCellMouseEventHandler(this.dataGridViewEx1_CellMouseClick);
        }
 public CustomerItem Customer_FindByID(int customerid)
 {
     using (var context = new ChinookSystemContext())
     {
         var results = context.Customers
                       .Where(x => x.CustomerId == customerid)
                       .Select(x => x)
                       .FirstOrDefault();
         CustomerItem item = new CustomerItem
         {
             CustomerId   = results.CustomerId,
             LastName     = results.LastName,
             FirstName    = results.FirstName,
             Company      = results.Company,
             Address      = results.Address,
             City         = results.City,
             State        = results.State,
             Country      = results.Country,
             PostalCode   = results.PostalCode,
             Phone        = results.Phone,
             Fax          = results.Fax,
             Email        = results.Email,
             SupportRepId = results.SupportRepId
         };
         return(item);
     }
 }
Exemplo n.º 10
0
        //public ActionResult UpdateUser(string key, string username, int gender, string address, string birthday, string fullname, string pass, int aid)
        //{
        //    if (key != Keyapi) return Json(0, JsonRequestBehavior.AllowGet);
        //    try
        //    {
        //        var model = _dl.GetByUserName(username);
        //        if (model != null)
        //        {
        //            model.Address = address;
        //            model.Gender = (gender == 1);
        //            if (aid > 0) model.AgencyID = aid;
        //            model.Birthday = ConvertUtil.ToDateTime(birthday).TotalSeconds();
        //            model.FullName = fullname;
        //            if (!string.IsNullOrEmpty(pass))
        //            {
        //                var sha1PasswordHash = FDIUtils.CreatePasswordHash(pass, model.PasswordSalt);
        //                model.PassWord = sha1PasswordHash;
        //            }
        //            _dl.Save();
        //            return Json(1, JsonRequestBehavior.AllowGet);
        //        }
        //    }
        //    catch (Exception e)
        //    {
        //        return Json(e.Message, JsonRequestBehavior.AllowGet);
        //    }
        //    return Json(3, JsonRequestBehavior.AllowGet);
        //}

        public ActionResult UpdateUser(CustomerItem customer)
        {
            try
            {
                var model = _dl.GetByUserID(CustomerId);
                if (model != null)
                {
                    model.Address              = customer.Address;
                    model.Gender               = (customer.Gender != null && customer.Gender.Value);
                    model.FullName             = customer.FullName;
                    model.Longitude            = customer.Longitude;
                    model.Latitude             = customer.Latitude;
                    model.LatitudeBuyRecently  = customer.LatitudeBuyRecently;
                    model.LongitudeBuyRecently = customer.LongitudeBuyRecently;
                    model.AddressBuyRecently   = customer.AddressBuyRecently;

                    _dl.Save();
                    return(Json(new JsonMessage(false, "Cập nhật thành công"), JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception e)
            {
                return(Json(new JsonMessage(true, e.Message), JsonRequestBehavior.AllowGet));
            }
            return(Json(new JsonMessage(true, "Đã có lỗi xảy ra"), JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 11
0
        public async Task <IActionResult> Edit(int id, [Bind("IdoutItemOrder,IdProduct,IdCustomerOrder,Quantity,Price")] CustomerItem customerItem)
        {
            if (id != customerItem.IdoutItemOrder)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(customerItem);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CustomerItemExists(customerItem.IdoutItemOrder))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdCustomerOrder"] = new SelectList(_context.CustomerOrder, "IdcustomerOrder", "IdcustomerOrder", customerItem.IdCustomerOrder);
            ViewData["IdProduct"]       = new SelectList(_context.Product, "Idproduct", "Product1", customerItem.IdProduct);
            return(View(customerItem));
        }
Exemplo n.º 12
0
        private List <ContactItem> GetContacts(CustomerItem Customer)
        {
            SQLHelper sh = new SQLHelper();
            DataTable dt = sh.GetData(@"SELECT [Reason]
                                          ,[Details]
                                          ,[DateContact]
                                          ,[Customers_Nas]
                                          ,[UserName],ContactID
                                      FROM [Odin].[dbo].[Contacts]
                                      WHERE [Customers_Nas] = @Customers_Nas order by DateContact desc", new List <string> {
                "@Customers_Nas"
            }, new List <object> {
                Customer.NAS
            }, CommandType.Text);
            List <ContactItem> Contacts = new List <ContactItem>();

            foreach (DataRow dr in dt.Rows)
            {
                ContactItem ci = new ContactItem();
                ci.Customers_Nas = dr["Customers_Nas"] != DBNull.Value ? dr["Customers_Nas"].ToString() : string.Empty;
                ci.DateContact   = dr["DateContact"] != DBNull.Value ? (DateTime)dr["DateContact"] : DateTime.MinValue;
                ci.Details       = dr["Details"] != DBNull.Value ? dr["Details"].ToString() : string.Empty;
                ci.Reason        = dr["Reason"] != DBNull.Value ? dr["Reason"].ToString() : string.Empty;
                ci.UserName      = dr["UserName"] != DBNull.Value ? dr["UserName"].ToString() : string.Empty;
                ci.ContactID     = dr["ContactID"] != DBNull.Value ? (Guid)dr["ContactID"] : Guid.Empty;
                Contacts.Add(ci);
            }

            return(Contacts);
        }
Exemplo n.º 13
0
        public IActionResult Update(long id, [FromBody] CustomerItem item)
        {
            if (item == null || item.CustomerId != id)
            {
                return(BadRequest());
            }

            var cust = _custRepo.Find(id);

            if (cust == null)
            {
                return(NotFound());
            }

            //todo.Name = item.Name;
            cust.FirstName     = item.FirstName;
            cust.LastName      = item.LastName;
            cust.Email         = item.Email;
            cust.Phone         = item.Phone;
            cust.Address       = item.Address;
            cust.City          = item.City;
            cust.State         = item.State;
            cust.PostalAddress = item.PostalAddress;

            _custRepo.Update(cust);
            return(new NoContentResult());
        }
Exemplo n.º 14
0
        public IActionResult Update(long id, [FromBody] CustomerItem item)
        {
            if (item == null || item.CustomerId != id)
            {
                return(BadRequest());
            }

            var customer = _customerRepository.Find(id);

            if (customer == null)
            {
                return(NotFound());
            }

            customer.FirstName     = item.FirstName;
            customer.LastName      = item.LastName;
            customer.Email         = item.Email;
            customer.Phone         = item.Phone;
            customer.Address       = item.Address;
            customer.City          = item.City;
            customer.Province      = item.Province;
            customer.PostalAddress = item.PostalAddress;

            _customerRepository.Update(customer);

            return(new NoContentResult());
        }
Exemplo n.º 15
0
        public List <TaxReturnItem> GetTaxReturns(CustomerItem Customer)
        {
            SQLHelper sh = new SQLHelper();
            DataTable dt = sh.GetData(@"SELECT [TaxYear]
                                  ,[status]
                                  ,[datestatus]
                                  ,[UserName]
                                  ,[Customers_Nas]
                              FROM [Odin].[dbo].[ReturnInfo]
                              where [Customers_Nas] = @NAS order by datestatus", new List <string> {
                "@NAS"
            }, new List <object> {
                Customer.NAS
            }, CommandType.Text);

            List <TaxReturnItem> TaxReturns = new List <TaxReturnItem>();

            foreach (DataRow dr in dt.Rows)
            {
                TaxReturnItem tr = new TaxReturnItem();
                tr.Customers_Nas = dr["Customers_Nas"] != DBNull.Value ? dr["Customers_Nas"].ToString() : string.Empty;
                tr.Datestatus    = dr["Datestatus"] != DBNull.Value ? (DateTime)dr["Datestatus"] : DateTime.MinValue;
                tr.Status        = dr["Status"] != DBNull.Value ? dr["Status"].ToString() : string.Empty;
                tr.TaxYear       = dr["TaxYear"] != DBNull.Value ? (int)dr["TaxYear"] : -1;
                tr.UserName      = dr["UserName"] != DBNull.Value ? dr["UserName"].ToString() : string.Empty;
                TaxReturns.Add(tr);
            }

            return(TaxReturns);
        }
        public decimal GetDiscount(List <CustomerItem> customerItems)
        {
            decimal promotionDiscount = 0.0M, productAmountDifference = 0.0M;
            int     firstProductcount = 0, secondProductcount = 0;

            productAmountDifference = FirstProduct.Price + SeconProduct.Price - PromotionAmount;
            CustomerItem firstproductItem = customerItems.Where(x => (x.Product.Name == FirstProduct.Name)).FirstOrDefault();

            if (firstproductItem == null)
            {
                return(promotionDiscount);
            }
            firstProductcount = firstproductItem.Quantity;
            CustomerItem secondProductItem = customerItems.Where(x => (x.Product.Name == SeconProduct.Name)).FirstOrDefault();

            if (secondProductItem == null)
            {
                return(promotionDiscount);
            }
            secondProductcount = secondProductItem.Quantity;

            promotionDiscount = Math.Min(firstProductcount, secondProductcount) * productAmountDifference;

            return(promotionDiscount);
        }
        public async Task <ActionResult <CustomerItem> > PostCustomerItem(CustomerItem item)
        {
            _context.CustomerItems.Add(item);
            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetCustomerItem), new { id = item.Id }, item));
        }
Exemplo n.º 18
0
        public ActionResult Login(string username, string password)
        {
            try
            {
                var customer = new CustomerItem();

                if (customerRepositoryFE.TryGetByUserNameAndPassword(out customer, username, password))
                {
                    if (!customer.IsActive)
                    {
                        return(Json(new
                        {
                            error = true,
                            message = "Tài khoản của bạn đã bị khóa."
                        }, JsonRequestBehavior.AllowGet));
                    }

                    var customerModel = new CustomerLoggedModel()
                    {
                        ID       = customer.ID,
                        FullName = customer.LastName,
                        Email    = customer.Email,
                        Phone    = customer.Phone,
                        UserName = customer.UserName,
                        Address  = customer.Address
                    };

                    Session["_cus"] = customerModel;

                    Response.Cookies.Add(new HttpCookie("_cus")
                    {
                        Value   = Web365Utility.Web365Utility.StringToBase64(JsonConvert.SerializeObject(customerModel)),
                        Expires = DateTime.Now.AddDays(1)
                    });

                    return(Json(new
                    {
                        error = false,
                        message = "Đăng nhập thành công"
                    }, JsonRequestBehavior.AllowGet));
                }

                return(Json(new
                {
                    error = true,
                    message = "Sai tên đăng nhập hoặc mật khẩu, bạn hãy thử lại."
                }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                Elmah.ErrorLog.GetDefault(null).Log(new Elmah.Error(ex));
            }

            return(Json(new
            {
                error = true,
                message = "Đăng nhập không thành công, bạn hãy thử lại"
            }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 19
0
        public void AddToCart(Product product, int quantity)
        {
            CustomerItem customerItem = new CustomerItem();

            customerItem.Product  = product;
            customerItem.Quantity = quantity;
            CustomerItems.Add(customerItem);
        }
Exemplo n.º 20
0
        public ctlTaxReturInfo(CustomerItem Customer, IModule Module)
        {
            this.Module   = Module;
            this.Customer = Customer;
            InitializeComponent();

            UpdateGV();
        }
Exemplo n.º 21
0
        private List <CustomerItem> LoadCustomers(string SearchValue)
        {
            try
            {
                SQLHelper sh = new SQLHelper();
                DataTable dt = sh.GetData(@"SELECT [Prenom]
                      ,[NomFamille]
                      ,[CodeClient]
                      ,[NAS]
                      ,[Ville]
                      ,[Rue]
                      ,[Numero]
                      ,[Province]
                      ,[Pays]
                      ,[CodePostal], [FileName]
                  FROM [Odin].[dbo].[Customers]
                  where CodeClient like @Search OR 
                       Prenom Like @Search OR
                        NomFamille Like @Search OR
                        NAS = @Search OR
                        Ville Like @Search OR
                        Rue Like @Search OR
                        Numero Like @Search OR
                        Province Like @Search OR
                        Pays Like @Search OR
                        CodePostal Like @Search OR
                        (Prenom + ' ' + NomFamille) Like @Search",
                                          new List <string> {
                    "@Search"
                },
                                          new List <object> {
                    SearchValue
                }, CommandType.Text);
                List <CustomerItem> Customers = new List <CustomerItem>();
                foreach (DataRow dr in dt.Rows)
                {
                    CustomerItem ci = new CustomerItem();
                    ci.CodeClient = dr["CodeClient"] != DBNull.Value ? dr["CodeClient"].ToString() : string.Empty;
                    ci.Prenom     = dr["Prenom"] != DBNull.Value ? dr["Prenom"].ToString() : string.Empty;
                    ci.NomFamille = dr["NomFamille"] != DBNull.Value ? dr["NomFamille"].ToString() : string.Empty;
                    ci.NAS        = dr["NAS"] != DBNull.Value ? dr["NAS"].ToString() : string.Empty;
                    ci.Ville      = dr["Ville"] != DBNull.Value ? dr["Ville"].ToString() : string.Empty;
                    ci.Rue        = dr["Rue"] != DBNull.Value ? dr["Rue"].ToString() : string.Empty;
                    ci.Numero     = dr["Numero"] != DBNull.Value ? dr["Numero"].ToString() : string.Empty;
                    ci.Province   = dr["Province"] != DBNull.Value ? dr["Province"].ToString() : string.Empty;
                    ci.Pays       = dr["Pays"] != DBNull.Value ? dr["Pays"].ToString() : string.Empty;
                    ci.CodePostal = dr["CodePostal"] != DBNull.Value ? dr["CodePostal"].ToString() : string.Empty;
                    ci.FileName   = dr["FileName"] != DBNull.Value ? dr["FileName"].ToString() : string.Empty;
                    Customers.Add(ci);
                }

                return(Customers);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Exemplo n.º 22
0
        public IActionResult Create([FromBody] CustomerItem item)
        {
            if (item == null)
            {
                return(BadRequest());
            }

            _CustomerRepository.Add(item);

            return(CreatedAtRoute("GetCustomer", new { id = item.Key }, item));
        }
Exemplo n.º 23
0
        public IActionResult Create([FromBody] CustomerItem item)
        {
            if (item == null)
            {
                return(BadRequest());
            }

            _custRepo.Add(item);

            return(CreatedAtRoute("GetCust", new { id = item.CustomerId }, item));
        }
Exemplo n.º 24
0
 public PageCustomer()
 {
     this.InitializeComponent();
     txtFooter.Text = App.GetAppTextFooter();
     //Load Customers in ComboBox
     CustomerOptions = new ObservableCollection <CustomerItem>();
     DBOptionsManager.GetAllCustomersList(CustomerOptions);
     _SelectedCustomer   = CustomerOptions[0];
     SelectedCustomer    = CustomerOptions[0];
     NavigationCacheMode = Windows.UI.Xaml.Navigation.NavigationCacheMode.Required;
 }
        public async Task <IActionResult> PutCustomerItem(long id, CustomerItem item)
        {
            if (id != item.Id)
            {
                return(BadRequest());
            }

            _context.Entry(item).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(NoContent());
        }
Exemplo n.º 26
0
        // populates customer details when an existing customer is selected from combobox
        private void comBoxSearchResult_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (comBoxSearchResult.SelectedIndex == -1)
            {
                return;
            }
            string       selectedCustomer = Convert.ToString(comBoxSearchResult.SelectedItem);
            CustomerItem customer         = DataLayerFacade.GetOneCustomerDetails(selectedCustomer);

            txtBoxCustName.Text    = customer.Name;
            txtBoxCustAddress.Text = customer.Address;
        }
Exemplo n.º 27
0
        public IActionResult Create([FromBody] CustomerItem item)
        {
            if (item == null)
            {
                return(BadRequest());
            }

            _context.CustomerItems.Add(item);
            _context.SaveChanges();

            return(CreatedAtRoute("GetCustomer", new { id = item.Id }, item));
        }
Exemplo n.º 28
0
        public async Task <IActionResult> Create([Bind("IdoutItemOrder,IdProduct,IdCustomerOrder,Quantity,Price")] CustomerItem customerItem)
        {
            if (ModelState.IsValid)
            {
                _context.Add(customerItem);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdCustomerOrder"] = new SelectList(_context.CustomerOrder, "IdcustomerOrder", "IdcustomerOrder", customerItem.IdCustomerOrder);
            ViewData["IdProduct"]       = new SelectList(_context.Product, "Idproduct", "Product1", customerItem.IdProduct);
            return(View(customerItem));
        }
Exemplo n.º 29
0
        public void Save(CustomerItem item)
        {
            item.GetValidationErrors().ThrowIfHasErrors();

            var customer = item.Id == 0 ? Db.CreateAndAdd <Customer>() : Db.Customers.Single(x => x.Id == item.Id);

            customer.Address = item.Address;
            customer.Name    = item.Name;
            customer.Notes   = item.Notes;
            customer.Phone   = item.Phone;

            Db.SaveChanges();
            item.Id = customer.Id;
        }
Exemplo n.º 30
0
        public bool TryGetById(out CustomerItem customer, int id)
        {
            customer = web365db.tblCustomer.Where(c => c.ID == id).Select(c => new CustomerItem()
            {
                ID        = c.ID,
                UserName  = c.UserName,
                FirstName = c.FirstName,
                LastName  = c.LastName,
                Email     = c.Email,
                Phone     = c.Phone,
                Address   = c.Address
            }).FirstOrDefault();

            return(customer != null);
        }