public async Task Should_Success_GetReport_with_order()
        {
            //Setup
            var serviceProvider          = GetServiceProvider();
            InventoryDbContext dbContext = _dbContext(GetCurrentMethod());

            InventorySummaryService inventorySummaryService = new InventorySummaryService(serviceProvider.Object, dbContext);

            serviceProvider.Setup(s => s.GetService(typeof(IInventorySummaryService)))
            .Returns(inventorySummaryService);

            InventoryMovementService inventoryMovementService = new InventoryMovementService(serviceProvider.Object, dbContext);

            serviceProvider.Setup(s => s.GetService(typeof(IInventoryMovementService)))
            .Returns(inventoryMovementService);

            InventoryDocumentService inventoryDocumentFacade = new InventoryDocumentService(serviceProvider.Object, dbContext);

            serviceProvider.Setup(s => s.GetService(typeof(IInventoryDocumentService)))
            .Returns(inventoryDocumentFacade);

            NewFpRegradingResultDocsService service = new NewFpRegradingResultDocsService(serviceProvider.Object, dbContext);
            var data = await _dataUtil(service).GetTestData();

            var orderProperty = new
            {
                Code = "desc"
            };
            string order = JsonConvert.SerializeObject(orderProperty);

            //Act
            var model = service.GetReport(null, null, null, null, null, null, null, 1, 25, order);

            //Assert
            Assert.NotNull(model);
        }
Exemple #2
0
 //GET ALL ITEM
 public JsonResult AllItem()
 {
     try
     {
         List <InventoryItem> item = new List <InventoryItem>();//requests = Requests model
         using (var context = new InventoryDbContext())
         {
             var allItem = from invItem in context.InventoryItem
                           join uom in context.UnitOfMeasurement
                           on invItem.UnitOfMeasurementId equals uom.UnitOfMeasurementId
                           select new
             {
                 InventoryItemID     = invItem.InventoryItemId,
                 ItemName            = invItem.ItemName,
                 UnitOfMeasurementID = uom.UnitOfMeasurementId,
                 UnitDescription     = uom.Description
             };
             item = allItem.Select(
                 ai => new InventoryItem
             {
                 InventoryItemID   = ai.InventoryItemID,
                 ItemName          = ai.ItemName,
                 UnitOfMeasurement = new UnitOfMeasurement
                 {
                     UnitOfMeasurementID = ai.UnitOfMeasurementID,
                     Description         = ai.UnitDescription
                 }
             }).ToList();
         }
         return(Json(item));
     }
     catch (Exception ex)
     {
         return(Json(ex.ToString()));
     }
 }
Exemple #3
0
        public async void TestDelete()
        {
            var options = new DbContextOptionsBuilder <InventoryDbContext>().UseSqlServer(connString).Options;
            InventoryItemModel inventoryItem = new InventoryItemModel();

            using (var context = new InventoryDbContext(options))
            {
                inventoryItem.ItemId          = 12;
                inventoryItem.ItemName        = "Brush";
                inventoryItem.ItemPrice       = 12;
                inventoryItem.ItemDescription = "Only 7 piece is remaining";
                inventoryItem.CreatedDate     = DateTime.Now;
                var test = new Inventory_Repository(context);
                await test.Delete(inventoryItem);
            }

            using (var context = new InventoryDbContext(options))
            {
                var test   = new Inventory_Repository(context);
                var result = await test.GetById(inventoryItem.ItemId);

                Assert.Null(result);
            }
        }
Exemple #4
0
 public ActionResult DBDeptStaff(string sessionId)
 {
     //as staff, main page to show current pending items and qty that are from requests that are not
     //cancelled, completed, or partialcomplete
     if (sessionId != null && userServices.getUserCountBySessionId(sessionId) == true)
     {
         using (var db = new InventoryDbContext())
         {
             User               user                   = db.users.Where(x => x.sessionId == sessionId).FirstOrDefault();
             String             department             = user.employee.departmentId;
             List <Requisition> departmentRequisitions = requestServices.getAllUncompleteRequisitions(department);
             departmentRequisitions.Sort();
             //use requisitions to create a list of all requisitions to find sum of all items and their quantities
             PendingItemsModel       pendingItems      = new PendingItemsModel();
             List <ProductCatalogue> productCatalogues = db.productCatalogues.ToList();
             foreach (Requisition requisition in departmentRequisitions)
             {
                 foreach (ProductReq productReq in requisition.productReqs)
                 {
                     ProductCatalogue pc       = productCatalogues.Where(x => x.itemNumber == productReq.productitemnumber).FirstOrDefault();
                     string           location = pc.location;
                     string           unit     = pc.unitofmeasure;
                     pendingItems.add(productReq.productitemnumber, productReq.productDesc, unit, productReq.quantity, location);
                 }
             }
             //sort pendingitems?
             ViewData["staffname"] = user.employee.empName;
             ViewData["sessionId"] = sessionId;
             return(View(pendingItems));
         }
     }
     else
     {
         return(RedirectToAction("Login", "Login"));
     }
 }
        public JsonResult ViewReq()
        {
            List <Request> requests = new List <Request>();

            using (var context = new InventoryDbContext())
            {
                requests = (from reqi in context.RequestItem
                            join inve in context.InventoryItem on reqi.InventoryItemId equals inve.InventoryItemId

                            join suppitem in context.SupplierInventoryItem on reqi.InventoryItemId equals suppitem.InventoryId into joined1
                            from suppitems in joined1.DefaultIfEmpty()

                            join supplier in context.Supplier on suppitems.SupplierId equals supplier.SupplierId into joined2
                            from suppliers in joined2.DefaultIfEmpty()

                            join req in context.Request on reqi.RequestId equals req.RequestId into joined
                            from reqs in joined.DefaultIfEmpty()

                            join loc in context.Location on reqs.LocationId equals loc.LocationId into joined6
                            from locs in joined6.DefaultIfEmpty()


                            select new Request
                {
                    RequestID = reqs.RequestId,
                    RequestName = suppliers.SupplierName,
                    RequisitionDates = reqs.RequestDate,
                    RequestLocation = locs.LocationName,
                    RequiredDates = reqs.RequiredDate,
                    RequestItem = inve.ItemName,
                    RequestQuanlity = reqi.Quantity,
                    RequestDesciption = reqi.Description,
                }).ToList();
            }
            return(Json(requests));
        }
        private void AddCustomers(InventoryDbContext context)
        {
            context.Customers.AddRange(
                new List <Entities.Customer>
            {
                new Entities.Customer
                {
                    Id   = 1,
                    Name = "Karen"
                },
                new Entities.Customer
                {
                    Id   = 2,
                    Name = "Ama"
                },
                new Entities.Customer
                {
                    Id   = 3,
                    Name = "Tsuku"
                }
            });

            context.SaveChanges();
        }
Exemple #7
0
        public async Task Should_Success_UpdateIsApprove()
        {
            var serviceProvider          = GetServiceProvider();
            InventoryDbContext dbContext = _dbContext(GetCurrentMethod());

            NewMaterialRequestNoteService serviceMrn = new NewMaterialRequestNoteService(serviceProvider.Object, dbContext);
            InventorySummaryService       inventorySummaryService = new InventorySummaryService(serviceProvider.Object, dbContext);

            serviceProvider.Setup(s => s.GetService(typeof(IInventorySummaryService)))
            .Returns(inventorySummaryService);

            InventoryMovementService inventoryMovementService = new InventoryMovementService(serviceProvider.Object, dbContext);

            serviceProvider.Setup(s => s.GetService(typeof(IInventoryMovementService)))
            .Returns(inventoryMovementService);

            InventoryDocumentService inventoryDocumentFacade = new InventoryDocumentService(serviceProvider.Object, dbContext);

            serviceProvider.Setup(s => s.GetService(typeof(IInventoryDocumentService)))
            .Returns(inventoryDocumentFacade);
            var mrn = await _dataUtilMrn(serviceMrn).GetTestData();

            serviceProvider.Setup(x => x.GetService(typeof(IMaterialRequestNoteService)))
            .Returns(serviceMrn);
            //serviceProvider.Setup(s => s.GetService(typeof(InventoryDocumentFacade)))
            //    .Returns(inventoryDocumentFacade);
            NewMaterialDistributionNoteService service = new NewMaterialDistributionNoteService(serviceProvider.Object, _dbContext(GetCurrentMethod()));
            var data = await _dataUtil(service, serviceMrn).GetTestData();

            var response = service.UpdateIsApprove(new List <int>()
            {
                data.Id
            });

            Assert.True(response);
        }
        static void InsertItems()
        {
            var items = new List <Item>()
            {
                new Item()
                {
                    Name = "Top Gun", IsActive = true, Description = "I feel the need, the need for speed"
                },
                new Item()
                {
                    Name = "Batman Begins", IsActive = true, Description = "You either die the hero or live long enough to see yourself become the villain"
                },
                new Item()
                {
                    Name = "Inception", IsActive = true, Description = "You mustn't be afraid to dream a little bigger"
                },
                new Item()
                {
                    Name = "Star Wars: The Empire Strikes Back", IsActive = true, Description = "He will join us or die, master"
                },
                new Item()
                {
                    Name = "Remember the Titans", IsActive = true, Description = "Attitude reflects leadership"
                }
            };

            using (var db = new InventoryDbContext(_optionsBuilder.Options))
            {
                foreach (var item in items)
                {
                    item.LastModifiedUserId = 1;
                }
                db.AddRange(items);
                db.SaveChanges();
            }
        }
Exemple #9
0
 // GET: Client/AddClient
 public JsonResult AddClient(Client client)
 {
     try
     {
         using (var context = new InventoryDbContext())
         {
             TableClient tblClient = new TableClient()
             {
                 ClientID   = client.ClientID,
                 ClientName = client.ClientName,
                 Address    = client.Address,
                 ContactNo  = client.ContactNo,
                 TinNo      = client.TinNo
             };
             context.TblClient.Add(tblClient);
             context.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         return(Json(ex.ToString()));
     }
     return(Json(string.Empty));
 }
Exemple #10
0
        //=====LOAD DATA=====//
        public JsonResult LoadPageData(Page page)
        {
            int           beginning = page.itemPerPage * (page.PageNumber - 1);
            List <Stocks> stocks    = new List <Stocks>();

            using (var context = new InventoryDbContext())
            {
                var computeRemainingQuantity = from invItem in context.InventoryItem
                                               join reqItem in context.RequisitionItem on invItem.InventoryItemId equals reqItem.InventoryItemId into joined
                                               from invItemj in joined.DefaultIfEmpty()
                                               join pdItem in context.PartialDeliveryItem on invItemj.RequisitionItemId equals pdItem.RequisitionItemId into joined2
                                               from reqItemj in joined2.DefaultIfEmpty()

                                               join reqs in context.Requisition on invItemj.RequisitionId equals reqs.RequisitionId into joined4
                                               from reqsj in joined4.DefaultIfEmpty()

                                               group new { invItem, reqItemj, invItemj } by new { invItem.InventoryItemId } into g
                    select new
                {
                    InventoryItemID   = g.FirstOrDefault().invItem.InventoryItemId,
                    RemainingQuantity = g.Sum(a => (a.reqItemj == null ? 0 : a.reqItemj.DeliveredQuantity)),

                    ReceiveQty = g.Sum(b => (b.invItemj == null ? 0 : b.invItemj.Quantity)),
                };

                var computeRequestedQuantity = from invItem in context.InventoryItem
                                               join reqItem in context.RequestItem on invItem.InventoryItemId equals reqItem.InventoryItemId into joined
                                               from invItemj in joined.DefaultIfEmpty()

                                               join req in context.Request on invItemj.RequestId equals req.RequestId into joined2
                                               from reqj in joined2.DefaultIfEmpty()

                                               //join reqsItem in context.RequisitionItem on invItem.InventoryItemId equals reqsItem.InventoryItemId into joined3
                                               //from invsItemj in joined3.DefaultIfEmpty()

                                               //join reqs in context.Requisition on invsItemj.RequisitionId equals reqs.RequisitionId into joined4
                                               //from reqsj in joined4.DefaultIfEmpty()

                                               where reqj == null || reqj.Status == "Accepted"
                                               group new { invItem, invItemj, reqj /*, invsItemj , reqsj*/ } by invItem.InventoryItemId into grouped
                    select new
                {
                    InventoryItemID = grouped.FirstOrDefault().invItem.InventoryItemId,
                    //lastquantity = grouped.Single(reqItem.Quantity),
                    QuantityRequest = grouped.Sum(a => (a.invItemj == null ? 0 : a.invItemj.Quantity)),
                    //ReceiveQty = grouped.Sum(a => (a.invsItemj == null ? 0 : a.invsItemj.Quantity)),
                    Status            = (grouped.FirstOrDefault().reqj == null) ? string.Empty : grouped.FirstOrDefault().reqj.Status,
                    LastRequestedDate = (grouped.FirstOrDefault().reqj == null) ? default(DateTime) : grouped.Max(a => a.reqj.RequestDate)
                };
                stocks = (from inv in context.InventoryItem
                          join uom in context.UnitOfMeasurement on inv.UnitOfMeasurementId equals uom.UnitOfMeasurementId


                          //join rq in context.RequestItem on inv.InventoryItemId equals rq.InventoryItemId  into joined3
                          //from rqy in joined3.DefaultIfEmpty()



                          join rq in context.RequestItem on inv.InventoryItemId equals rq.RequestItemId into joined3
                          from rqy in joined3.DefaultIfEmpty()



                          join remainingQty in computeRemainingQuantity on inv.InventoryItemId equals remainingQty.InventoryItemID into joined
                          from remainingQtyj in joined.DefaultIfEmpty()

                          join requestedQty in computeRequestedQuantity on inv.InventoryItemId equals requestedQty.InventoryItemID into joined2
                          from requestedQtyj in joined2.DefaultIfEmpty()

                          //join rq in computeRequestedQuantity on inv.InventoryItemId equals rq.InventoryItemID into joined3
                          //from rqy in joined3.DefaultIfEmpty()


                          //join rq in computeRequestedQuantity on inv.InventoryItemId equals rq.InventoryItemID into joined3
                          //from rqy in joined3.DefaultIfEmpty()



                          select new Stocks
                {
                    InventoryItemID = inv.InventoryItemId,
                    ItemName = inv.ItemName,
                    UnitOfDescription = uom.Description,
                    ItemCode = inv.ItemCode,
                    ItemBegBal = inv.ItemBegBal,
                    TotalStock = remainingQtyj == null ? 0 : remainingQtyj.RemainingQuantity,
                    RequestedQuantity = requestedQtyj == null ? 0 : requestedQtyj.QuantityRequest,

                    LatestQuantity = remainingQtyj == null ? 0 : remainingQtyj.ReceiveQty,

                    //  LatestQuantity = rqy.Quantity.ToString(),

                    LastRequestedDate = requestedQtyj.LastRequestedDate,
                }).OrderByDescending(e => e.LastRequestedDate).Skip(beginning).Take(page.itemPerPage).ToList().ToList();
            }
            return(Json(stocks));
        }
Exemple #11
0
 public InventoryRepository(InventoryDbContext context) : base(context)
 {
 }
 public InventoryCompanyService(IOptions <MyConfiguration> _config)
 {
     connString = _config.Value.Connectionstring;
     db         = new InventoryDbContext(connString);
 }
Exemple #13
0
        public ActionResult CreateDelegation(string employeeName, Delegation d, string sessionId)
        {
            if (sessionId != null && userServices.getUserCountBySessionId(sessionId) == true)
            {
                bool       overlap = false;
                Delegation del     = new Delegation();
                del.delegateToName = employeeName;
                del.startDate      = d.startDate;
                del.endDate        = d.endDate;

                if ((util.IsDateValid(del.startDate, del.endDate)) == true)
                {
                    //check for delegation period overlap between the new delegation and those in database
                    using (var db = new InventoryDbContext())
                    {
                        User u = db.users.Where(x => x.sessionId == sessionId).FirstOrDefault();
                        List <Delegation> dels = new List <Delegation>();
                        dels = db.delegations.Where(x => x.Department.id == u.employee.Department.id).ToList();

                        foreach (var c in dels)
                        {
                            if (DateTime.Compare(del.endDate, c.startDate) < 0)
                            {
                                overlap = false;
                            }
                            else if (DateTime.Compare(del.startDate, c.endDate) > 0)
                            {
                                overlap = false;
                            }
                            else
                            {
                                overlap = true;
                                break;
                            }
                        }
                    }
                    if (overlap == false)
                    {
                        using (var db = new InventoryDbContext())
                        {
                            User user = db.users.Where(x => x.employee.empName == employeeName).FirstOrDefault();
                            List <Delegation> deles = new List <Delegation>();
                            deles = db.delegations.Where(x => x.Department.id == user.employee.Department.id).ToList();

                            //link the employee to the delagation obj usng employee id
                            del.employeeId = user.employeeId;
                            del.employee   = user.employee;
                            del.Department = user.employee.Department;
                            del.status     = "ACTIVE";
                            db.delegations.Add(del);
                            db.SaveChanges();
                            return(RedirectToAction("Existdelegation", new { sessionId }));
                        }
                    }
                    //if fall to here, there is overlap with current delegation. as such, send msg
                    return(RedirectToAction("DHdelegation", new { sessionId, msg = "*Delegation overlaps with another existing delegation. Please check.*" }));
                }
                else
                {
                    return(RedirectToAction("DHdelegation", new { sessionId, msg = "*Please enter Valid date*" }));
                }
            }
            else
            {
                return(RedirectToAction("Login", "Login"));
            }
        }
Exemple #14
0
        static void Main(string[] args)
        {
            BuildOptions();
            BuildMapper();

            var minDate = new DateTime(2020, 1, 1);
            var maxDate = new DateTime(2021, 1, 1);

            using (var db = new InventoryDbContext(_optionsBuilder.Options))
            {
                var svc = new ItemsService(db, _mapper);
                Console.WriteLine("List Inventory");
                var inventory = svc.ListInventory();
                inventory.ForEach(x => Console.WriteLine($"New Item: {x}"));

                Console.WriteLine("List inventory with Linq");
                var items = svc.GetItemsForListingLinq(minDate, maxDate);
                items.ForEach(x => Console.WriteLine($"ITEM| {x.CategoryName}| {x.Name} - {x.Description}"));

                Console.WriteLine("List Inventory from procedure");
                var procItems = svc.GetItemsForListingFromProcedure(minDate, maxDate);
                procItems.ForEach(x => Console.WriteLine($"ITEM| {x.Name} - {x.Description}"));

                Console.WriteLine("Item Names Pipe Delimited String");
                var pipedItems = svc.GetItemsPipeDelimitedString(true);
                Console.WriteLine(pipedItems.AllItems);

                Console.WriteLine("Get Items Total Values");
                var totalValues = svc.GetItemsTotalValues(true);
                totalValues.ForEach(item => Console.WriteLine($"New Item] {item.Id,-10}" +
                                                              $"|{item.Name,-50}" +
                                                              $"|{item.Quantity,-4}" +
                                                              $"|{item.TotalValue,-5}"));

                Console.WriteLine("Get Items With Genres");
                var itemsWithGenres = svc.GetItemsWithGenres();
                itemsWithGenres.ForEach(item => Console.WriteLine($"New Item] {item.Id,-10}" +
                                                                  $"|{item.Name,-50}" +
                                                                  $"|{item.Genre?.ToString().PadLeft(4)}"));

                Console.WriteLine("List Categories And Colors");
                var categoriesAndColors = svc.ListCategoriesAndColors();
                categoriesAndColors.ForEach(c => Console.WriteLine($"{c.Category} | {c.CategoryColor.Color}"));

                _categories = categoriesAndColors;
                Console.WriteLine("Would you like to create items?");
                var createItems = Console.ReadLine().StartsWith("y", StringComparison.OrdinalIgnoreCase);
                if (createItems)
                {
                    Console.WriteLine("Adding new Item(s)");
                    CreateMultipleItems(svc);
                    Console.WriteLine("Items added");

                    inventory = svc.ListInventory();
                    inventory.ForEach(x => Console.WriteLine($"Item: {x}"));
                }

                Console.WriteLine("Would you like to update items?");
                var updateItems = Console.ReadLine().StartsWith("y", StringComparison.OrdinalIgnoreCase);
                if (updateItems)
                {
                    Console.WriteLine("Updating Item(s)");
                    UpdateMultipleItems(svc);
                    Console.WriteLine("Items updated");

                    inventory = svc.ListInventory();
                    inventory.ForEach(x => Console.WriteLine($"Item: {x}"));
                }

                Console.WriteLine("Would you like to delete items?");
                var deleteItems = Console.ReadLine().StartsWith("y", StringComparison.OrdinalIgnoreCase);
                if (deleteItems)
                {
                    Console.WriteLine("Deleting Item(s)");
                    DeleteMultipleItems(svc);
                    Console.WriteLine("Items Deleted");

                    inventory = svc.ListInventory();
                    inventory.ForEach(x => Console.WriteLine($"Item: {x}"));
                }
            }
            Console.WriteLine("Program Complete");
        }
        //GET ALL PENDING REQUEST
        public JsonResult AllPendingRequest()
        {
            try
            {
                List <Account> account  = new List <Account>(); //account = Account model
                List <Request> requests = new List <Request>(); //requests = Requests model

                using (var context = new InventoryDbContext())  //Use DbInventory
                {
                    //SELECT ALL REQUEST FROM DbInventory
                    requests = (from req in context.Request
                                join loc in context.Location
                                on req.LocationId equals loc.LocationId
                                select new Request
                    {
                        RequestID = req.RequestId,
                        SpecialInstruction = req.SpecialInstruction,
                        RequisitionDate = req.RequestDate,
                        RequiredDate = req.RequiredDate,
                        RequisitionType = req.RequisitionType,
                        Status = req.Status,
                        LocationID = loc.LocationId,
                        LocationName = loc.LocationName,
                        UserID = req.UserId
                    }).ToList();
                }

                using (var context = new AccountDbContext())//Use dbAccount
                {
                    var userIDs = requests.Select(b => b.UserID);

                    //SELECT ALL USER FROM DbAccount
                    account = (from user in context.Users
                               where userIDs.Contains(user.UserId)
                               select new Account
                    {
                        UserID = user.UserId,
                        Firstname = user.Firstname,
                        Middlename = user.Middlename,
                        Lastname = user.Lastname,
                        Department = user.Department,
                        Contact = user.Contact,
                        Email = user.Email,
                    }).ToList();
                }

                //JOIN TABLE USER AND TABLE REQUEST
                requests = (from req in requests
                            join acc in account
                            on req.UserID equals acc.UserID
                            where req.Status == "Pending"
                            select new Request
                {
                    RequestID = req.RequestID,

                    Firstname = acc.Firstname,
                    Middlename = acc.Middlename,
                    Lastname = acc.Lastname,
                    Department = acc.Department,
                    Contact = acc.Contact,
                    Email = acc.Email,

                    SpecialInstruction = req.SpecialInstruction,
                    RequisitionDateString = req.RequisitionDate.ToString(),
                    RequiredDateString = req.RequiredDate.ToString(),
                    RequisitionType = req.RequisitionType,
                    Status = req.Status,

                    LocationID = req.LocationID,
                    LocationName = req.LocationName
                }).ToList();
                return(Json(requests));//Return as json
            }
            catch (Exception ex)
            {
                return(Json(ex.ToString()));
            }
        }
Exemple #16
0
 public AddStoreProductPriceHandler(InventoryDbContext dbContext)
 {
     _dbContext = dbContext;
 }
        //VIEW REQUEST ITEM
        public JsonResult RequestItem(int requestID)
        {
            try
            {
                List <RequestItem> requestItem = new List <RequestItem>();//Exam = Exam model
                using (var context = new InventoryDbContext())
                {
                    var displayItem = from req in context.Request
                                      join reqItem in context.RequestItem
                                      on req.RequestId equals reqItem.RequestId
                                      join inv in context.InventoryItem
                                      on reqItem.InventoryItemId equals inv.InventoryItemId
                                      join uom in context.UnitOfMeasurement
                                      on inv.UnitOfMeasurementId equals uom.UnitOfMeasurementId
                                      where reqItem.RequestId == requestID
                                      select new
                    {
                        InventoryItemId    = inv.InventoryItemId,
                        ItemName           = inv.ItemName,
                        UnitDescription    = uom.Description,
                        Quantity           = reqItem.Quantity,
                        ItemDescription    = reqItem.Description,
                        SpecialInstruction = req.SpecialInstruction
                    };
                    requestItem = displayItem.Select(
                        ri => new RequestItem
                    {
                        InventoryItemID   = ri.InventoryItemId,
                        ItemName          = ri.ItemName,
                        UnitOfMeasurement = ri.UnitDescription,
                        Quantity          = ri.Quantity,
                        Description       = ri.ItemDescription
                    }).ToList();
                }

                //DataTable dtRequestItem = dbManager.SqlReader(
                //           "SELECT " +
                //                "i.InventoryItemId,i.Name,uom.Description as uomDesc,ri.Quantity,ri.Description,r.SpecialInstruction " +
                //            "FROM " +
                //                "DB_INVENTORY.dbo.tbl_Request r " +
                //            "JOIN " +
                //                "DB_ACCOUNTS.dbo.tbl_User u " +
                //            "ON " +
                //                "r.UserId = u.UserId " +
                //            "JOIN " +
                //                "DB_INVENTORY.dbo.tbl_RequestItem ri " +
                //            "ON " +
                //                "r.RequestId = ri.RequestId " +
                //            "JOIN " +
                //                "DB_INVENTORY.dbo.tbl_InventoryItem i " +
                //            "ON " +
                //                "i.InventoryItemId = ri.InventoryItemId " +
                //            "JOIN " +
                //                "tbl_UnitOfMeasurement uom " +
                //            "ON " +
                //                "i.UnitOfMeasurementId = uom.UnitOfMeasurementId " +
                //            "WHERE " +
                //                 "ri.RequestId = @requestid"
                //            , "tblRequestItem", parameters);
                return(Json(requestItem));
            }
            catch (Exception ex)
            {
                return(Json(ex.ToString()));
            }
        }
Exemple #18
0
        //This function is complete transaction after dispatch items. Transactions as below
        //1)Save Dispatched Items,                          2)Save Stock Transaction
        //3) Update Stock model (available Quantity)        4) Update Requisition and Requisition Items (Status and ReceivedQty,PendingQty, etc)
        public static Boolean DispatchItemsTransaction(RequisitionStockVM requisitionStockVMFromClient, InventoryDbContext inventoryDbContext)
        {
            //Transaction Begin
            using (var dbContextTransaction = inventoryDbContext.Database.BeginTransaction())
            {
                try
                {
                    //Save Dispatched Items
                    AddDispatchItems(inventoryDbContext, requisitionStockVMFromClient.dispatchItems);
                    #region Logic for -Set ReferenceNo in StockTransaction Model from DispatchItems
                    //This for get ReferenceNO (DispatchItemsId from Dispatched Items) and save to StockTransaction
                    foreach (var stockTXN in requisitionStockVMFromClient.stockTransactions)
                    {
                        var ItemId          = 0;
                        var DispatchId      = 0;
                        var stockIdFromsTXN = stockTXN.StockId;

                        foreach (var stkItem in requisitionStockVMFromClient.stock)
                        {
                            if (stkItem.StockId == stockIdFromsTXN)
                            {
                                ItemId = stkItem.ItemId;
                            }
                        }
                        foreach (var dItem in requisitionStockVMFromClient.dispatchItems)
                        {
                            if (ItemId == dItem.ItemId)
                            {
                                DispatchId = dItem.DispatchItemsId;
                            }
                        }

                        stockTXN.ReferenceNo = DispatchId;
                    }
                    #endregion
                    //Save Stock Transaction record
                    AddStockTransaction(inventoryDbContext, requisitionStockVMFromClient.stockTransactions);
                    //Update Stock records
                    UpdateStock(inventoryDbContext, requisitionStockVMFromClient.stock);
                    //Update Requisition and Requisition Items after Dispatche Items
                    UpdateRequisitionWithRItems(inventoryDbContext, requisitionStockVMFromClient.requisition);

                    //Update Ward Inventory
                    UpdateWardInventory(inventoryDbContext, requisitionStockVMFromClient.dispatchItems);
                    //Commit Transaction
                    dbContextTransaction.Commit();
                    return(true);
                }
                catch (Exception ex)
                {
                    //Rollback all transaction if exception occured
                    dbContextTransaction.Rollback();
                    throw ex;
                }
            }
        }
 public InventorySummaryFacade(IServiceProvider serviceProvider, InventoryDbContext dbContext)
 {
     this.serviceProvider = serviceProvider;
     this.dbContext       = dbContext;
     this.dbSet           = dbContext.Set <InventorySummary>();
 }
Exemple #20
0
 //This is Used for WriteOff or may be for other purpose
 public static List <StockModel> GetStockItemsByItemIdBatchNO(int ItemId, string BatchNO, InventoryDbContext inventoryDBContext)
 {
     try
     {
         if (BatchNO == "NA")
         {
             BatchNO = string.Empty;
         }
         List <StockModel> stockItems = (from stock in inventoryDBContext.Stock
                                         where stock.ItemId == ItemId && stock.BatchNO == BatchNO
                                         select stock
                                         ).ToList();
         return(stockItems);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #21
0
 public EquipmentDistributionRepository(InventoryDbContext context)
 {
     _context = context;
 }
Exemple #22
0
        //This function is complete transaction for DISPATCH-ALL.
        //1)Save Dispatched Items,                          2)Save Stock Transaction
        //3) Update Stock model (available Quantity)        4) Update Requisition and Requisition Items (Status and ReceivedQty,PendingQty)
        public static Boolean DispatchAllTransaction(RequisitionsStockVM requisitionStockVMFromClient, InventoryDbContext inventoryDbContext)
        {
            //Transaction Begin
            using (var dbContextTransaction = inventoryDbContext.Database.BeginTransaction())
            {
                try
                {
                    //Save Dispatched Items
                    AddDispatchItems(inventoryDbContext, requisitionStockVMFromClient.dispatchItems);
                    //This for get ReferenceNO (DispatchItemsId from Dispatched Items) and save to StockTransaction
                    foreach (var stockTXN in requisitionStockVMFromClient.stockTransactions)
                    {
                        var DispatchId = 0;
                        var ReqItemId  = stockTXN.requisitionItemId;
                        foreach (var dItem in requisitionStockVMFromClient.dispatchItems)
                        {
                            if (ReqItemId == dItem.RequisitionItemId)
                            {
                                DispatchId = dItem.DispatchItemsId;
                            }
                        }
                        stockTXN.ReferenceNo = DispatchId;
                    }
                    //Save Stock Transaction record
                    AddStockTransaction(inventoryDbContext, requisitionStockVMFromClient.stockTransactions);
                    //Update Stock records
                    UpdateStock(inventoryDbContext, requisitionStockVMFromClient.stocks);
                    //Update Requisition and Requisition Items after Dispatche Items
                    UpdateRequisitionandRItems(inventoryDbContext, requisitionStockVMFromClient.requisitions);

                    //Commit Transaction
                    dbContextTransaction.Commit();
                    return(true);
                }
                catch (Exception ex)
                {
                    //Rollback all transaction if exception occured
                    dbContextTransaction.Rollback();
                    throw ex;
                }
            }
        }
 public GarmentLeftoverWarehouseReportExpenditureService(IServiceProvider serviceProvider, InventoryDbContext dbContext)
 {
     DbContext       = dbContext;
     ServiceProvider = serviceProvider;
     IdentityService = serviceProvider.GetService <IIdentityService>();
     GarmentShippingLocalCoverLetterUri = APIEndpoint.PackingInventory + "garment-shipping/local-cover-letters";
     GarmentCoreProductUri = APIEndpoint.Core + "master/garmentProducts";
 }
Exemple #24
0
 public StoreCachedRepository(IRepository <Store> storeRepository, InventoryDbContext context) : base(context)
 {
     this.storeRepository = storeRepository;
     //this.cacheService = cacheService;
 }
 public Repository(InventoryDbContext context)
 {
     Context = context;
     _dbSet  = Context.Set <TEntity>();
 }
Exemple #26
0
 public Repository()
 {
     context = new InventoryDbContext();
     DbSet   = context.Set <T>();
 }
 public LocationController(InventoryDbContext context)
 {
     _context = context;
 }
Exemple #28
0
 public DictionaryRepository(InventoryDbContext context)
     : base(context)
 {
 }
Exemple #29
0
 public CustomerDataController(InventoryDbContext context)
     : base(context)
 {
 }
 public GarmentLeftoverWarehouseMutationReportService(InventoryDbContext dbContext, IServiceProvider serviceProvider)
 {
     DbContext       = dbContext;
     ServiceProvider = serviceProvider;
     IdentityService = (IIdentityService)serviceProvider.GetService(typeof(IIdentityService));
 }