public ActionResult AssignmentDetail(int AnchorTransactionID, int TransactionTypeID)
        {
            ViewBag.Title   = "";
            ViewBag.Message = "";

            AssignmentBussines.GetAssignmentRequest request = new AssignmentBussines.GetAssignmentRequest()
            {
                AssignmentID = AnchorTransactionID,
            };
            TransactionConfigurateBussines.GetTransactionConfigurateRequest requestTransaction = new TransactionConfigurateBussines.GetTransactionConfigurateRequest()
            {
                AnchorTransactionID = AnchorTransactionID,
                TransactionTypeID   = TransactionTypeID
            };

            AssignmentBussines.GetAssignmentResponse c = AssignmentBussines.Select.GetAssignment(request);
            int to = TransactionConfigurateBussines.Select.GetTotalAmountToTransaction(requestTransaction).TotalAmount;

            request.ProductID = (int)c.Assignment.idProduct;

            var model = new AssignmentViewModels()
            {
                Error                = c.Error,
                total                = to,
                Assignment           = c.Assignment,
                Transaction          = new Transactions(),
                TransactionList      = TransactionConfigurateBussines.Select.GetTransactionList(requestTransaction).TransactionList,
                ProductList          = ProductBussines.Select.GetProduct().ProductList,
                AssignmentList       = AssignmentBussines.Select.GetAssignmentByProductID(request).AssignmentList,
                ProviderList         = ProviderBussines.Select.GetProviderList().ProviderList,
                ConditionProductList = ConditionProductBussines.Select.GetConditionProductList().ConditionProductList
            };

            return(PartialView(model));
        }
        public ActionResult AssignmentCreate(string FatherCateogryID, string CategoryID, string CellarArea)
        {
            ViewBag.Title   = "";
            ViewBag.Message = "";
            ProductBussines.GetProductRequest request = new ProductBussines.GetProductRequest()
            {
                CellarAreaID = Convert.ToInt16(CellarArea),
                CategoryID   = Convert.ToInt16(CategoryID.ToString())
            };



            var model = new AssignmentViewModels()
            {
                Assignment           = new Assignments(),
                CategoryID           = CategoryID,
                CategoryIDFhater     = FatherCateogryID,
                CellarArea           = CellarArea,
                ProductList          = ProductBussines.Select.GetProductListByDepartmentAndCategory(request, Convert.ToInt16(FatherCateogryID)).ProductList,
                EmployeesList        = EmployeeBussines.Select.GetEmployeeList().EmployeeList,
                ConditionProductList = ConditionProductBussines.Select.GetConditionProductList().ConditionProductList
            };

            model.Assignment.idCategory = Convert.ToInt16(CategoryID);


            return(PartialView(model));
        }
        public ActionResult AssignmentView(string CategoryID, string FatherCateogryID, string CellarArea, bool successful = false, string ResultAction = "")
        {
            ViewBag.Title      = "";
            ViewBag.successful = successful;
            ViewBag.Message    = ResultAction;

            AssignmentBussines.GetAssignmentRequest request = new AssignmentBussines.GetAssignmentRequest()
            {
                CategoryID        = Convert.ToInt16(CategoryID),
                TransactionTypeID = 2
            };
            AssignmentBussines.GetAssignmentRequest requestFather = new AssignmentBussines.GetAssignmentRequest()
            {
                CategoryID = Convert.ToInt16(CategoryID)
            };

            var BussinesData = AssignmentBussines.Select.GetAssignmentList(request);
            var model        = new AssignmentViewModels()
            {
                Error                = BussinesData.Error,
                CategoryID           = CategoryID,
                CategoryIDFhater     = FatherCateogryID,
                CellarArea           = CellarArea,
                AssignmentList       = BussinesData.AssignmentList,
                GetCategoryName      = CategoryBussines.Select.GetCategoryName(Convert.ToInt16(CategoryID)).Category.name,
                GetCategoryFaherName = CategoryBussines.Select.GetCategoryName(Convert.ToInt16(FatherCateogryID)).Category.name,
                ConditionProductList = ConditionProductBussines.Select.GetConditionProductList().ConditionProductList
            };

            return(View(model));
        }
        public ActionResult AssignmentUpdate(int id, string CategoryID, string FatherCateogryID, string CellarArea)
        {
            AssignmentBussines.GetAssignmentRequest request = new AssignmentBussines.GetAssignmentRequest()
            {
                AssignmentID = id,
            };
            AssignmentBussines.GetAssignmentResponse a = AssignmentBussines.Select.GetAssignment(request);
            request.ProductID = (int)a.Assignment.idProduct;

            ProductBussines.GetProductRequest request2 = new ProductBussines.GetProductRequest()
            {
                ProductID = (int)a.Assignment.idProduct
            };
            var model = new AssignmentViewModels()
            {
                Error            = a.Error,
                Assignment       = a.Assignment,
                CategoryID       = CategoryID,
                CategoryIDFhater = FatherCateogryID,
                CellarArea       = CellarArea,
                EmployeesList    = EmployeeBussines.Select.GetEmployeeList().EmployeeList
            };

            ViewBag.Title   = "Update Asignment To " + ProductBussines.Select.GetProduct(request2).Product.name;
            ViewBag.Message = "";

            return(PartialView(model));
        }
        public ActionResult AssignmentUpdate(AssignmentViewModels data)
        {
            AssignmentBussines.GetAssignmentResponse assignmentData = new AssignmentBussines.GetAssignmentResponse()
            {
                Assignment = data.Assignment
            };

            result = AssignmentBussines.Update.Assignments(assignmentData).Message;

            return(RedirectToAction("AssignmentView", new { CategoryID = data.CategoryID, FatherCateogryID = data.CategoryIDFhater, CellarArea = data.CellarArea, successful = true, ResultAction = "All Changes was successful" }));
        }
        public ActionResult AssignmentNewInflow(string CategoryID, string FatherCateogryID, string CellarArea, int AnchorTransactionID, int TransactionTypeID)
        {
            ViewBag.Title   = "";
            ViewBag.Message = "";

            AssignmentBussines.GetAssignmentRequest request = new AssignmentBussines.GetAssignmentRequest()
            {
                AssignmentID = AnchorTransactionID,
            };
            TransactionConfigurateBussines.GetTransactionConfigurateRequest requestTransaction = new TransactionConfigurateBussines.GetTransactionConfigurateRequest()
            {
                AnchorTransactionID = AnchorTransactionID,
                TransactionTypeID   = TransactionTypeID
            };
            ProductBussines.GetProductRequest requestProduct = new ProductBussines.GetProductRequest()
            {
                CellarAreaID = Convert.ToInt16(CellarArea)
            };

            AssignmentBussines.GetAssignmentResponse c = AssignmentBussines.Select.GetAssignment(request);
            int to = TransactionConfigurateBussines.Select.GetTotalAmountToTransaction(requestTransaction).TotalAmount;

            request.ProductID = (int)c.Assignment.idProduct;

            var model = new AssignmentViewModels()
            {
                Error                = c.Error,
                total                = to,
                Assignment           = c.Assignment,
                Transaction          = new Transactions(),
                TransactionList      = TransactionConfigurateBussines.Select.GetTransactionList(requestTransaction).TransactionList,
                AssignmentList       = AssignmentBussines.Select.GetAssignmentByProductID(request).AssignmentList,
                ConditionProductList = ConditionProductBussines.Select.GetConditionProductList().ConditionProductList,



                CategoryID       = CategoryID,
                CategoryIDFhater = FatherCateogryID,
                CellarArea       = CellarArea,
                ProductList      = ProductBussines.Select.GetProductByAssignmentType(requestProduct).ProductList,
                EmployeesList    = EmployeeBussines.Select.GetEmployeeList().EmployeeList,
            };

            model.Assignment.idCategory = Convert.ToInt16(CategoryID);


            return(PartialView(model));
        }
        public ActionResult AssignmentNewInflow(AssignmentViewModels data)
        {
            AssignmentBussines.GetAssignmentResponse assignmentData = new AssignmentBussines.GetAssignmentResponse()
            {
                Assignment  = data.Assignment,
                transaction = data.Transaction
            };

            AssignmentBussines.GetAssignmentRequest request = new AssignmentBussines.GetAssignmentRequest()
            {
                AssignmentID      = data.Assignment.id,
                TransactionTypeID = 2,
                CellarArea        = Convert.ToInt16(data.CellarArea),
                amount            = (int)data.Assignment.amount + (int)data.Transaction.amount
            };

            result = AssignmentBussines.Update.Assignment(assignmentData, request).Message;

            return(RedirectToAction("AssignmentView", new { CategoryID = data.CategoryID, FatherCateogryID = data.CategoryIDFhater, CellarArea = data.CellarArea, successful = true, ResultAction = "All Changes was successful" }));
        }
        public ActionResult InstructorWithCourses()
        {
            SqlConnection con = new SqlConnection(connection);

            con.Open();
            List <AssignmentViewModels> lists = new List <AssignmentViewModels>();
            string        query = "select FirstName,LastName,Name,Title from Person inner join Instructor on Person.Id=Instructor.InstructorId inner join AssignInstructor on Instructor.InstructorId=AssignInstructor.InstructorId inner join Course on AssignInstructor.CourseId=Course.Id inner join Department on Course.DepartmentId = Department.Id ";
            SqlCommand    cmd   = new SqlCommand(query, con);
            SqlDataReader rdr   = cmd.ExecuteReader();

            while (rdr.Read())
            {
                var intsWithCourse = new AssignmentViewModels();

                intsWithCourse.FirstName = rdr[0].ToString();
                intsWithCourse.LastName  = rdr[1].ToString();
                intsWithCourse.Name      = rdr[2].ToString();
                intsWithCourse.Title     = rdr[3].ToString();

                lists.Add(intsWithCourse);
            }
            rdr.Close();
            return(View(lists));
        }