Example #1
0
        public void GenerateDisbursement(int retrId, LUUser user)
        {
            List <Disbursement> dibursements = disbDao.GenerateDisbursebents(retrId);

            foreach (Disbursement dis in dibursements)
            {
                Core.Controller.NotificationController ctl = new NotificationController();
                ctl.CreateNotification(
                    user.UserID, string.Format("The Items has been Shipped {0}. Disbursement key =", dis.Key), NotificationStatus.Created, Roles.HOD, dis.DepartmentID.Value
                    );
                ctl.CreateNotification(
                    user.UserID, string.Format("The Items has been Shipped {0}. Disbursement key =", dis.Key), NotificationStatus.Created, Roles.REP, dis.DepartmentID.Value
                    );


                string toEmailIdsHOD  = new UserController().GetToEmailIds(Roles.HOD, dis.DepartmentID.Value); //To which role the email should be sent
                string toEmailIdsREPS = new UserController().GetToEmailIds(Roles.HOD, dis.DepartmentID.Value);
                ctl.SendEmail("*****@*****.**", toEmailIdsHOD, "Items for requsition has been shiped", "The disbursement key while receiving item is : " + dis.Key);
                ctl.SendEmail("*****@*****.**", toEmailIdsREPS, "Items for requsition has been shiped", "The disbursement key while receiving item is : " + dis.Key);
            }
        }
Example #2
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            LUUser user = (LUUser)Session["User"];

            if (user == null)
            {
                throw new InvalidOperationException("User Is not valid");
            }
            if (ViewState["items"] != null)
            {
                items = (List <CartItem>)ViewState["items"];
                RequisitionItemDao dao         = new RequisitionItemDao();
                Requisition        requisition = new Requisition();
                requisition.ReqDate      = System.DateTime.Now;
                requisition.ReqNumber    = requisitionNum;          //Todo
                requisition.Status       = RequisitionStatus.Requested.ToString();
                requisition.RequesterID  = user.UserID;             // Todo: need to change later once login up
                requisition.DepartmentID = user.DepartmentID.Value; // Todo: same
                requisition.RecieveByID  = user.Department.HodID;   //Todo: same
                requisition.Remark       = tbRemarks.Text;
                dao.db.Requisitions.Add(requisition);
                foreach (var cartItem in items)
                {
                    RequisitionItem item = new RequisitionItem();
                    item.SupplierItemID = cartItem.SupplierItem.SupplierItemId;
                    item.NeededQuantity = cartItem.Quantity;
                    item.ReqID          = requisition.ReqID;
                    item.IsOutstanding  = false;
                    dao.db.RequisitionItems.Add(item);
                }
                dao.db.SaveChanges();

                #region Send Notifications

                NotificationController ctl = new NotificationController();
                ctl.CreateNotification(
                    user.UserID, string.Format("New approval Requisition request {0}", requisition.ReqNumber), NotificationStatus.Created, Roles.HOD, user.DepartmentID.Value
                    );
                string toEmailIds = new UserController().GetToEmailIds(Roles.HOD, user.DepartmentID.Value); //To which role the email should be sent
                ctl.SendEmail("*****@*****.**", toEmailIds, "New requisition approval request", "New Requisition has been for approval : " + requisition.ReqNumber);

                #endregion

                reset();
                Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "alertRedirect('Requested Submited for Approval !!!','EmpMain.aspx')", true);
            }
        }
Example #3
0
        public async Task CreateNotification()
        {
            Notification notification = new Notification()
            {
                NotificationID  = 1,
                Message         = "Tornado is coming!",
                MessageDateTime = DateTime.Now,
                SendingUserID   = 19,
                IncidentID      = 1
            };
            //Arrange
            var controller = new NotificationController(_dao, _authService, new Microsoft.Extensions.Logging.LoggerFactory(), _sms, _email);

            //Act success
            var result = await controller.CreateNotification(notification);

            //Assert success
            var failureResult = Assert.IsType <OkObjectResult>(result);
        }
        public async Task CreateNotificationTest()
        {
            // Arrange

            // Act
            var id           = 0;
            var notification = new NotificationDTO
            {
                Id       = id,
                Receiver = testUserName
            };
            var response = await _controller.CreateNotification(notification);

            // Assert
            NotificationDTO notificationResponse;

            Assert.IsTrue(response.TryGetContentValue <NotificationDTO>(out notificationResponse));
            Assert.AreNotEqual(id, notificationResponse.Id);
            Assert.AreEqual(FormatUserName(testUserName), notificationResponse.Receiver);
        }
Example #5
0
        public void CreateNotification_ActionExecutes_ReturnsOk()
        {
            var result = _controller.CreateNotification(new Notification());

            Assert.IsType <OkObjectResult>(result);
        }