public ActionResult UpdateCollectionPoint(int idDisbursement, int idCollectionPt)
        {
            //int idEmployee = 4;
            int      idEmployee    = (int)Session["IdEmployee"];
            int      IdStoreClerk1 = _disbursementDAO.FindById(idDisbursement).IdDisbursedBy.GetValueOrDefault(0);//old clerk
            string   cp1           = _disbursementDAO.FindById(idDisbursement).CollectionPoint.Location;
            string   cp2           = _collectionPointDAO.Find(idCollectionPt).Location;
            Employee employee      = _employeeDAO.FindEmployeeById(idEmployee);

            bool result1 = _departmentDAO.UpdateCollectionPt(employee.CodeDepartment, idCollectionPt);
            bool result2 = _disbursementDAO.UpdateCollectionPt(idDisbursement, idCollectionPt);

            var hub           = GlobalHost.ConnectionManager.GetHubContext <ChatHub>();
            int IdStoreClerk2 = _disbursementDAO.FindById(idDisbursement).IdDisbursedBy.GetValueOrDefault(0);//new clerk

            hub.Clients.All.receiveNotification(IdStoreClerk1);
            hub.Clients.All.receiveNotification(IdStoreClerk2);
            EmailClass emailClass = new EmailClass();
            string     message    = "Hi," + _employeeDAO.FindEmployeeById(IdStoreClerk1).Name +
                                    employee.Name + "from Department " + employee.CodeDepartment + "has changed the Collection Point from " + cp1 + " to " + cp2 + ".";

            _notificationChannelDAO.CreateNotificationsToIndividual(IdStoreClerk1, (int)Session["IdEmployee"], message);
            emailClass.SendTo(_employeeDAO.FindEmployeeById(IdStoreClerk1).Email, "SSIS System Email", message);

            message = "Hi," + _employeeDAO.FindEmployeeById(IdStoreClerk2).Name +
                      employee.Name + "from Department " + employee.CodeDepartment + "has changed the Collection Point from " + cp1 + " to " + cp2 + ".";
            _notificationChannelDAO.CreateNotificationsToIndividual(IdStoreClerk2, (int)Session["IdEmployee"], message);
            emailClass.SendTo(_employeeDAO.FindEmployeeById(IdStoreClerk2).Email, "SSIS System Email", message);



            return(RedirectToAction("Home"));
        }
Exemplo n.º 2
0
        public JsonResult UpdateQuantity(DisbursementModel model)
        {
            int              id             = model.id;
            string           disbursementId = model.disbursementId;
            List <ItemModel> items          = model.items;

            //int id, string disbursementId, JArray items

            if (String.IsNullOrEmpty(disbursementId))
            {
                return(Json(new { status = "Bad" }, JsonRequestBehavior.AllowGet));
            }

            Disbursement d = _disbursementDAO.FindById(Int32.Parse(disbursementId));



            if (d == null)
            {
                return(Json(new { status = "Bad" }, JsonRequestBehavior.AllowGet));
            }
            else if (d.Status.Label.Equals("Received"))
            {
                return(Json(new { status = "Bad" }, JsonRequestBehavior.AllowGet));
            }

            bool isAuth = false;

            foreach (CPClerk cpclerk in d.CollectionPoint.CPClerks)
            {
                if (cpclerk.IdStoreClerk == id)
                {
                    isAuth = true;
                }
            }
            if (isAuth == false)
            {
                return(Json(new { status = "Bad" }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                _disbursementItemDAO.UpdateQuantityIssued(Int32.Parse(disbursementId), items);
            }

            return(Json(new { status = "Ok" }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 3
0
        public ActionResult Schedule(IEnumerable <int> disbIdsToSchedule, String pickDate)
        {
            /*            if (Session["IdEmployee"] == null || (String)Session["Role"] != "StockClerk")
             *              return RedirectToAction("Login", "Home");*/

            int IdStoreClerk = 1;

            if (Session["IdEmployee"] != null)
            {
                IdStoreClerk = (int)Session["IdEmployee"];
            }



            if (disbIdsToSchedule != null)
            {
                // schedule for selected date by setting the date from the form
                DateTime SDate = DateTime.ParseExact(pickDate, "yyyy-MM-dd",
                                                     System.Globalization.CultureInfo.InvariantCulture);

                _disbursementDAO.UpdateStatus(disbIdsToSchedule, 10, SDate, null);

                // add in notification here upon updating status
                foreach (var disbId in disbIdsToSchedule)
                {
                    Disbursement targetDisbursement = _disbursementDAO.FindById(disbId);
                    // Get Dep Rep
                    Employee depRep = targetDisbursement.Department.Employees
                                      .Where(emp => emp.IdRole == 3)
                                      .FirstOrDefault();

                    String message = (targetDisbursement.DisbursementItems.ToList().All(i => i.UnitIssued >= i.UnitRequested)) ?
                                     $"Your department's request will be ready for collection on {SDate.ToString("dd/MM/yyyy")}." :
                                     $"Your department's request will be ready for collection on {SDate.ToString("dd/MM/yyyy")}. " +
                                     $"We are currently unable to prepare the full quantity of requested items from your department.";

                    int notifId = _notificationDAO.CreateNotification(message);
                    _notificationChannelDAO.SendNotification(IdStoreClerk, depRep.IdEmployee, notifId, DateTime.Now);
                    var hub = GlobalHost.ConnectionManager.GetHubContext <ChatHub>();
                    hub.Clients.All.receiveNotification(depRep.IdEmployee);
                    EmailClass emailClass = new EmailClass();
                    emailClass.SendTo(depRep.Email, "SSIS System Email", message);
                }
            }

            return(RedirectToAction("Disbursement"));
        }