コード例 #1
0
            public async Task <int> Handle(ChangeEventStatusToForApprovalCommand request, CancellationToken cancellationToken)
            {
                var _event = dbContext.Events.Find(request.ID);

                if (_event != null)
                {
                    _event.EventStatus = Status.ForApproval;
                    await dbContext.SaveChangesAsync();

                    return(_event.ID);
                }

                else
                {
                    throw new Exception("Event doesnt exist");
                }
            }
コード例 #2
0
            public async Task <bool> Handle(ChangeEventStatusToClosedCommand request, CancellationToken cancellationToken)
            {
                var _qVal = dbContext.Events
                            .Where(a => a.ID == request.EventID)
                            .SingleOrDefault();

                if (_qVal != null)
                {
                    _qVal.EventStatus = Status.Closed;
                    await dbContext.SaveChangesAsync();

                    return(true);
                }
                else
                {
                    throw new Exception("Event doesnt exist");
                }
            }
コード例 #3
0
            public async Task <bool> Handle(AddFoodDetailsCommand request, CancellationToken cancellationToken)
            {
                Food _foodDetails = new Food
                {
                    Code          = request.MyFoodDetailsVM.Code,
                    Name          = request.MyFoodDetailsVM.Name,
                    Specification = request.MyFoodDetailsVM.Specification,
                    Description   = request.MyFoodDetailsVM.Description,
                    Unit          = request.MyFoodDetailsVM.Unit,
                    FoodType      = request.MyFoodDetailsVM.FoodType,
                    CreatedOn     = DateTime.Now
                };

                dbContext.Foods.Add(_foodDetails);
                await dbContext.SaveChangesAsync();

                return(true);
            }
コード例 #4
0
            public async Task <bool> Handle(AddEquipmentDetailsCommand request, CancellationToken cancellationToken)
            {
                Equipment _equipmentDetails = new Equipment
                {
                    Code          = request.MyEquipmentsDetailsVM.Code,
                    Name          = request.MyEquipmentsDetailsVM.Name,
                    Description   = request.MyEquipmentsDetailsVM.Description,
                    RentalFee     = request.MyEquipmentsDetailsVM.RentalFee,
                    UnitType      = request.MyEquipmentsDetailsVM.UnitType,
                    EquipmentType = request.MyEquipmentsDetailsVM.EquipmentType,
                    CreatedOn     = DateTime.Now
                };

                dbContext.Equipments.Add(_equipmentDetails);
                await dbContext.SaveChangesAsync();

                return(true);
            }
コード例 #5
0
            public async Task <bool> Handle(DeclineEventRequirementsCommand request, CancellationToken cancellationToken)
            {
                try
                {
                    var _declineId = dbContext.Events.Where(a => a.ID == request.DeclineEventID && a.EventStatus == Status.Approved).SingleOrDefault();

                    if (_declineId != null)
                    {
                        _declineId.EventStatus = Status.CheckingRequirements;
                        await dbContext.SaveChangesAsync();
                    }

                    return(true);
                }
                catch (Exception)
                {
                    throw;
                }
            }
コード例 #6
0
            public async Task <bool> Handle(ApproveEventRequirementsCommand request, CancellationToken cancellationToken)
            {
                try
                {
                    var _approveId = dbContext.Events.Where(a => a.ID == request.ApproveEventID).SingleOrDefault();

                    if (_approveId != null)
                    {
                        _approveId.EventStatus = Status.RequirementsComplete;
                        await dbContext.SaveChangesAsync();
                    }

                    return(true);
                }
                catch (Exception)
                {
                    throw;
                }
            }
コード例 #7
0
            public async Task <bool> Handle(CheckOutEquipmentStockCommand request, CancellationToken cancellationToken)
            {
                bool response = new bool();

                var _getEquipmentStockDetails = dbContext.EquipmentInventories.Find(request.MyEquipmentInventoryVM.EquipmentDetailsID);

                if (_getEquipmentStockDetails != null)
                {
                    _getEquipmentStockDetails.Quantity -= request.MyEquipmentInventoryVM.Quantity;

                    EquipmentTracking _checkOutRecord = new EquipmentTracking
                    {
                        EventID            = request.MyEquipmentInventoryVM.EventDetailsID,
                        EquipmentID        = request.MyEquipmentInventoryVM.EquipmentDetailsID,
                        InventoryManagerID = request.MyEquipmentInventoryVM.UserID,
                        Quantity           = request.MyEquipmentInventoryVM.Quantity,
                        TrackingDate       = DateTime.Now,
                        TrackingAction     = EquipmentAction.CheckOut,
                        Remarks            = request.MyEquipmentInventoryVM.Remarks,
                        CreatedOn          = DateTime.Now,
                        Returned           = false
                    };

                    dbContext.EquipmentTracking.Add(_checkOutRecord);

                    if (_getEquipmentStockDetails.Quantity > 0)
                    {
                        await dbContext.SaveChangesAsync();

                        response = true;
                    }
                    else
                    {
                        response = false;
                    }

                    return(response);
                }
                else
                {
                    throw new Exception("Equipment Stock ID does not exist!");
                }
            }
コード例 #8
0
            public async Task <bool> Handle(AddEquipmentInventoryCommand request, CancellationToken cancellationToken)
            {
                EquipmentInventory _equipmentInventory = new EquipmentInventory
                {
                    Quantity           = request.MyEquipmentsInventoryVM.Quantity,
                    EncodingDate       = DateTime.Now,
                    ItemPrice          = request.MyEquipmentsInventoryVM.ItemPrice,
                    Remarks            = request.MyEquipmentsInventoryVM.Remarks,
                    InventoryManagerID = request.MyEquipmentsInventoryVM.UserID,
                    EquipmentID        = request.MyEquipmentsInventoryVM.EquipmentDetailsID,
                    DeliveryID         = request.MyEquipmentsInventoryVM.DeliveryDetailsID,
                    CreatedOn          = DateTime.Now
                };

                dbContext.EquipmentInventories.Add(_equipmentInventory);
                await dbContext.SaveChangesAsync();

                return(true);
            }
コード例 #9
0
            public async Task <bool> Handle(DeleteFoodRestockRequestCommand request, CancellationToken cancellationToken)
            {
                var _getFoodRestockRequest = dbContext.FoodRestockRequests.Find(request.DeleteRequestID);

                if (_getFoodRestockRequest != null)
                {
                    var _getFoodRestockCollection = dbContext.FoodRequestCollections.Where(a => a.FoodRestockRequestID == request.DeleteRequestID).ToList();

                    dbContext.FoodRestockRequests.Remove(_getFoodRestockRequest);
                    dbContext.FoodRequestCollections.RemoveRange(_getFoodRestockCollection);
                }
                else
                {
                    throw new Exception("Request ID does not exist!");
                }

                await dbContext.SaveChangesAsync();

                return(true);
            }
コード例 #10
0
            public async Task <bool> Handle(DeleteEquipmentDetailsCommand request, CancellationToken cancellationToken)
            {
                var _deleteEquipmentDetails = dbContext.Equipments.Find(request.DeleteSearchedID);

                if (_deleteEquipmentDetails != null)
                {
                    dbContext.Equipments.Remove(_deleteEquipmentDetails);

                    var _deleteEquipmentInventory = dbContext.EquipmentInventories.Where(a => a.EquipmentID == request.DeleteSearchedID).ToList();
                    dbContext.EquipmentInventories.RemoveRange(_deleteEquipmentInventory);

                    await dbContext.SaveChangesAsync();

                    return(true);
                }
                else
                {
                    throw new Exception("Equipment ID does not exist!");
                }
            }
コード例 #11
0
            public async Task <bool> Handle(UpdateFoodDetailsCommand request, CancellationToken cancellationToken)
            {
                var _updatedFoodDetails = dbContext.Foods.Find(request.MyFoodDetailsVM.ID);

                if (_updatedFoodDetails != null)
                {
                    _updatedFoodDetails.Code          = request.MyFoodDetailsVM.Code;
                    _updatedFoodDetails.Name          = request.MyFoodDetailsVM.Name;
                    _updatedFoodDetails.Specification = request.MyFoodDetailsVM.Specification;
                    _updatedFoodDetails.Description   = request.MyFoodDetailsVM.Description;
                    _updatedFoodDetails.Unit          = request.MyFoodDetailsVM.Unit;
                    _updatedFoodDetails.FoodType      = request.MyFoodDetailsVM.FoodType;

                    await dbContext.SaveChangesAsync();

                    return(true);
                }
                else
                {
                    throw new Exception("Food ID does not exist!");
                }
            }
コード例 #12
0
            public async Task <EventVM> Handle(ApproveEventRequestCommand request, CancellationToken cancellationToken)
            {
                var _toApprove = dbContext.Events
                                 .Where(a => a.ID == request.EventID)
                                 .Include(a => a.Coordinator).SingleOrDefault();

                if (_toApprove != null)
                {
                    _toApprove.EventStatus = Status.Approved;
                    await dbContext.SaveChangesAsync();

                    var _toReturn = new EventVM {
                        ID          = _toApprove.ID,
                        EventName   = _toApprove.EventName,
                        Coordinator = _toApprove.Coordinator
                    };
                    return(_toReturn);
                }
                else
                {
                    throw new Exception("Does not exist!");
                }
            }
コード例 #13
0
            public async Task <bool> Handle(UpdateEquipmentDetailsCommand request, CancellationToken cancellationToken)
            {
                var _updatedEquipmentDetails = dbContext.Equipments.Find(request.MyEquipmentDetails.ID);

                if (_updatedEquipmentDetails != null)
                {
                    _updatedEquipmentDetails.Code          = request.MyEquipmentDetails.Code;
                    _updatedEquipmentDetails.Name          = request.MyEquipmentDetails.Name;
                    _updatedEquipmentDetails.Description   = request.MyEquipmentDetails.Description;
                    _updatedEquipmentDetails.RentalFee     = request.MyEquipmentDetails.RentalFee;
                    _updatedEquipmentDetails.UnitType      = request.MyEquipmentDetails.UnitType;
                    _updatedEquipmentDetails.EquipmentType = request.MyEquipmentDetails.EquipmentType;

                    await dbContext.SaveChangesAsync();

                    return(true);
                }

                else
                {
                    throw new Exception("Equipment ID does not exist!");
                }
            }
コード例 #14
0
            public async Task <FoodRequestVM> Handle(ApproveFoodRestockRequestCommand request, CancellationToken cancellationToken)
            {
                var _requestToApproved = dbContext.FoodRestockRequests
                                         .Where(a => a.ID == request.RequestID)
                                         .Include(a => a.InventoryManager).SingleOrDefault();

                if (_requestToApproved != null)
                {
                    _requestToApproved.Status = Status.Approved;
                    await dbContext.SaveChangesAsync();

                    var _toReturn = new FoodRequestVM
                    {
                        ID = _requestToApproved.ID,
                        InventoryManager = _requestToApproved.InventoryManager
                    };

                    return(_toReturn);
                }
                else
                {
                    throw new Exception("Does not exist!");
                }
            }