Exemple #1
0
        /*  public void WriteBillingProduct(CheckDetails product)
         * {
         *    string directory = Directory.GetCurrentDirectory() + "\\tempFiles\\";
         *    DataContractJsonSerializer jsonFormatter = new DataContractJsonSerializer(typeof(int));
         *    int? userId = null;
         *
         *    using (FileStream fs = new FileStream(directory + "Seller.json", FileMode.OpenOrCreate))
         *    {
         *        userId = (int)jsonFormatter.ReadObject(fs);
         *    }
         *
         *    jsonFormatter = new DataContractJsonSerializer(typeof(List<CheckDetails>));
         *
         *    List<CheckDetails> listOfBilling = new List<CheckDetails>();
         *
         *    using (FileStream fs = new FileStream(directory + "Billing_Employee_" + userId + ".json", FileMode.OpenOrCreate))
         *    {
         *        try
         *        {
         *            listOfBilling = (List<CheckDetails>)jsonFormatter.ReadObject(fs);
         *        }
         *        catch (SerializationException ex)
         *        {
         *
         *        }
         *    }
         *
         *    listOfBilling.Add(product);
         *
         *    using (FileStream fs = new FileStream(directory + "Billing_Employee_" + userId + ".json", FileMode.OpenOrCreate))
         *    {
         *        jsonFormatter.WriteObject(fs, listOfBilling);
         *    }
         * }*/

        /* public CheckDetails GetInfoCheckDetailsFromFileById(int? checkDetailsId)
         * {
         *   string directory = Directory.GetCurrentDirectory() + "\\tempFiles\\";
         *   DataContractJsonSerializer jsonFormatter = new DataContractJsonSerializer(typeof(int));
         *   int? userId = null;
         *
         *   using (FileStream fs = new FileStream(directory + "Seller.json", FileMode.OpenOrCreate))
         *   {
         *       userId = (int)jsonFormatter.ReadObject(fs);
         *   }
         *   DataContractJsonSerializer jsonFormatterList = new DataContractJsonSerializer(typeof(List<CheckDetails>));
         *
         *   List<CheckDetails> listOfBilling = null;
         *
         *   using (FileStream fs = new FileStream(directory + "Billing_Employee_" + userId + ".json", FileMode.OpenOrCreate))
         *   {
         *       try
         *       {
         *           listOfBilling = (List<CheckDetails>)jsonFormatterList.ReadObject(fs);
         *       }
         *       catch (SerializationException ex)
         *       {
         *           CheckDetails checkDetailsNull = new CheckDetails();
         *           return checkDetailsNull;
         *       }
         *   }
         *
         *   CheckDetails checkDetails = listOfBilling.Where(c => c.CheckDetailsId == checkDetailsId).SingleOrDefault();
         *   return checkDetails;
         * }*/

        public int CountOfFurniture(CheckDetails checkDetails)
        {
            FurnitureInStorage furniture = Context.FurnitureInStorage
                                           .Where(c => c.FurnitureId == checkDetails.FurnitureId).SingleOrDefault();

            return(furniture.QuantityInStorage);
        }
Exemple #2
0
        public FurnitureSale FormBillForClientWithDiscount()
        {
            string directory = Directory.GetCurrentDirectory() + "\\tempFiles\\";
            DataContractJsonSerializer jsonFormatter = new DataContractJsonSerializer(typeof(int));
            int?customerId = null;
            int employeeId = 0;

            using (FileStream fs = new FileStream(directory + "Customer.json", FileMode.Open))
            {
                customerId = (int)jsonFormatter.ReadObject(fs);
            }

            using (FileStream fs = new FileStream(directory + "Seller.json", FileMode.Open))
            {
                employeeId = (int)jsonFormatter.ReadObject(fs);
            }

            decimal totalSum = CalculateTotalSumOfBillWithDiscount(customerId);

            FurnitureSale customerCheck = new FurnitureSale
            {
                BuyingDate = DateTime.Now,
                CustomerId = customerId,
                EmployeeId = employeeId,
                TotalPrice = totalSum
            };

            furnitureSaleRepository.Create(customerCheck);

            IEnumerable <CheckDetails> list       = checkDetailsRepository.GetMultipleCheckDetailsInfo(m => m.CheckId == null);
            List <CheckDetails>        listOfBill = list.ToList();

            List <FurnitureInStorage> furnitureInStorageList = new List <FurnitureInStorage>();

            for (int i = 0; i < listOfBill.Count; i++)
            {
                FurnitureInStorage furniture = furnitureInStorageRepository.GetFurnitureInStorageForBillById(listOfBill[i].FurnitureId);

                furnitureInStorageList.Add(furniture);

                listOfBill[i].CheckId = customerCheck.CheckId;
                furnitureInStorageList[i].QuantityInStorage -= listOfBill[i].QuantitySelected;

                checkDetailsRepository.Update(listOfBill[i]);
                furnitureInStorageRepository.Update(furnitureInStorageList[i]);
            }

            return(furnitureSaleRepository.GetInfoAboutConfirmedBill(customerCheck));
        }
Exemple #3
0
 public IActionResult Create([Bind("FurnitureId,CatalogId,StorageId,WholesalePrice,RetailPrice,QuantityInStorage")] FurnitureInStorage furnitureInStorage)
 {
     if (ModelState.IsValid)
     {
         if (furnitureInStorage.WholesalePrice > furnitureInStorage.RetailPrice)
         {
             this.ModelState["RetailPrice"].Errors.Clear();
             this.ModelState["RetailPrice"].Errors.Add("Ціна на продаж не може бути меншою, ніж ціна закупівлі товару!");
             ViewData["CatalogId"] = new SelectList(_furnitureRepository.GetNotAddedFurnitureToStorage(), "CatalogId", "FurnitureName", furnitureInStorage.CatalogId);
             ViewData["StorageId"] = new SelectList(_storageRepository.GetStorageWithShop(), "StorageId", "StorageAddress", furnitureInStorage.StorageId);
             return(View(furnitureInStorage));
         }
         _furnitureInStorageRepository.Create(furnitureInStorage);
         return(RedirectToAction(nameof(Index)));
     }
     ViewData["CatalogId"] = new SelectList(_furnitureRepository.GetNotAddedFurnitureToStorage(), "CatalogId", "FurnitureName", furnitureInStorage.CatalogId);
     ViewData["StorageId"] = new SelectList(_storageRepository.GetStorageWithShop(), "StorageId", "StorageAddress", furnitureInStorage.StorageId);
     return(View(furnitureInStorage));
 }
Exemple #4
0
 public IActionResult Search([Bind("CatalogId, StorageId")] FurnitureInStorage furnitureStorage)
 {
     return(RedirectToAction("IndexSingle", new { catalogId = furnitureStorage.CatalogId, storageId = furnitureStorage.StorageId }));
 }