Ejemplo n.º 1
0
        //
        // GET: /Default/SaleInfo/

        public ActionResult Index()
        {
            SaleInfoModel saleInfoModel = new SaleInfoModel();

            saleInfoModel.Managers = managerRepository.Items;
            saleInfoModel.Products = productRepository.Items;
            return(View(saleInfoModel));
        }
        public ActionResult DeleteSaleInfoR(int id)
        {
            var saleInfo = new SaleInfoModel()
            {
                Id = id
            };

            return(PartialView("DeleteSaleInfoView", saleInfo));
        }
        public ActionResult EditSaleInfo(SaleInfoModel saleInfo)
        {
            List <string> _errList = new List <string>();
            bool          _success = false;

            if (ModelState.IsValid)
            {
                try
                {
                    var sin = new SaleInfo(saleInfo.Date,
                                           new FileInformation(saleInfo.FileName, saleInfo.Date,
                                                               new Manager(saleInfo.ManagerName)),
                                           new Client(saleInfo.ClientFirstName, saleInfo.ClientSecondName),
                                           new Product(saleInfo.ProductName), saleInfo.Cost);

                    new SaleInfoRepository().Update(saleInfo.Id, sin);
                    _success = true;
                }
                catch (DalException e)
                {
                    _errList.Add(e.Message);
                }
                catch (Exception)
                {
                    _errList.Add("DataBase Error");
                }
            }
            else
            {
                _errList = GetModelErrors();
            }

            return(Json(new
            {
                success = _success,
                error = _errList
            }));
        }
        public ActionResult AddSaleInfo()
        {
            var saleInfo = new SaleInfoModel();

            return(PartialView("AddSaleInfoView", saleInfo));
        }