public ActionResult Index()
        {
            statusService          = new StatusService(context);
            userService            = new UserService(context);
            collectionPointService = new CollectionPointService(context);

            List <Status> list = new List <Status>();

            list.Add(statusService.FindStatusByStatusId(0));
            list.Add(statusService.FindStatusByStatusId(1));
            List <ApplicationUser> allUsersList        = userService.FindAllUsers();
            List <CollectionPoint> collectionPointList = collectionPointService.FindAllCollectionPoints();

            return(View(new DepartmentViewModel
            {
                Statuses = new SelectList(
                    list.Select(x => new { Value = x.StatusId, Text = x.Name }),
                    "Value",
                    "Text"
                    ),
                AllUsers = new SelectList(
                    allUsersList.Select(x => new { value = x.Email, text = x.FirstName + " " + x.LastName }),
                    "Value",
                    "Text"
                    ),
                CollectionPoints = new SelectList(
                    collectionPointList.Select(x => new { value = x.CollectionPointId, text = x.Name }),
                    "Value",
                    "Text"
                    )
            }));
        }
 public DepartmentRepController(EmployeeService es, DepartmentService ds, CollectionPointService cps, Emailservice ems)
 {
     this.ds  = ds;
     this.es  = es;
     this.cps = cps;
     this.ems = ems;
 }
        public ActionResult DepartmentOptions()
        {
            departmentService      = new DepartmentService(context);
            collectionPointService = new CollectionPointService(context);
            userService            = new UserService(context);

            List <ApplicationUser> userByDepartmentList = departmentService.FindUsersByDepartment(userService.FindUserByEmail(CurrentUserName).Department);
            List <CollectionPoint> collectionPointList  = collectionPointService.FindAllCollectionPoints();
            CollectionPoint        collectionPoint      = collectionPointService.FindCollectionPointByDepartment(userService.FindUserByEmail(CurrentUserName).Department);
            ApplicationUser        departmentRep        = userService.FindRepresentativeByDepartment(userService.FindUserByEmail(CurrentUserName).Department);

            return(View(new DepartmentViewModel
            {
                UsersByDepartment = new SelectList(
                    userByDepartmentList.Select(x => new { value = x.Email, text = x.FirstName + " " + x.LastName }),
                    "Value",
                    "Text"
                    ),
                CollectionPoints = new SelectList(
                    collectionPointList.Select(x => new { value = x.CollectionPointId, text = x.Name }),
                    "Value",
                    "Text"
                    ),
                CollectionPoint = collectionPoint.CollectionPointId.ToString(), //sets current value as default value on dropdownlist
                DepartmentRep = departmentRep.Email
            }));
        }
        public ActionResult Save(DepartmentViewModel model)
        {
            departmentService      = new DepartmentService(context);
            collectionPointService = new CollectionPointService(context);
            userService            = new UserService(context);
            statusService          = new StatusService(context);

            bool       status = false;
            Department dpt    = new Department();

            if (departmentService.FindDepartmentByDepartmentCode(model.DepartmentCode) == null)
            {
                //new dpt
                dpt.DepartmentCode  = model.DepartmentCode;
                dpt.CreatedDateTime = DateTime.Now;
                dpt.CreatedBy       = userService.FindUserByEmail(System.Web.HttpContext.Current.User.Identity.GetUserName());
                dpt.Representative  = userService.FindUserByEmail(model.DepartmentRep);
            }

            else
            {
                //edit dpt
                dpt = departmentService.FindDepartmentByDepartmentCode(model.DepartmentCode);

                //assign user info into update fields
                dpt.UpdatedDateTime = DateTime.Now;
                //dpt.UpdatedBy = userService.FindUserByEmail(System.Web.HttpContext.Current.User.Identity.GetUserName());
                dpt.UpdatedBy = userService.FindUserByEmail(CurrentUserName);
            }

            dpt.Name = model.DepartmentName;
            dpt.Head = userService.FindUserByEmail(model.EmailHead);

            dpt.CollectionPoint = collectionPointService.FindCollectionPointById(Convert.ToInt32(model.CollectionPointId));
            dpt.ContactName     = model.ContactName;
            dpt.PhoneNumber     = model.PhoneNumber;
            dpt.FaxNumber       = model.FaxNumber;
            dpt.Status          = statusService.FindStatusByStatusId(model.Status);

            //save info to database
            if (departmentService.Save(dpt) != null)
            {
                status = true;
            }

            return(new JsonResult {
                Data = new { status = status }
            });
        }
        public RequisitionController()
        {
            context = new ApplicationDbContext();
            requisitionRepository = new RequisitionRepository(context);
            userRepository        = new UserRepository(context);

            requisitionService     = new RequisitionService(context);
            retrievalService       = new RetrievalService(context);
            itemService            = new ItemService(context);
            collectionPointService = new CollectionPointService(context);
            departmentService      = new DepartmentService(context);
            statusService          = new StatusService(context);

            userManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(context));
        }
예제 #6
0
 public HomeController(ILogger <HomeController> logger,
                       EmployeeService empService,
                       RequisitionService rfService,
                       StationeryRetrievalFormService srfService,
                       DisbursementFormProductService dfpService,
                       DashboardService dashService,
                       DelegationService delService,
                       CollectionPointService cpService)
 {
     _logger          = logger;
     this.empService  = empService;
     this.rfService   = rfService;
     this.srfService  = srfService;
     this.dfpService  = dfpService;
     this.dashService = dashService;
     this.delService  = delService;
     this.cpService   = cpService;
 }
 public CollectionPointController(CollectionPointService cps, EmployeeService es)
 {
     this.cps = cps;
     this.es  = es;
 }
예제 #8
0
 public AccountController(ILogger <AccountController> logger, EmployeeService empService, CollectionPointService cpService)
 {
     _logger         = logger;
     this.empService = empService;
     this.cpService  = cpService;
 }
 public void TestInitialize()
 {
     // Arrange
     context = new ApplicationDbContext();
     collectionPointService = new CollectionPointService(context);
 }
 public DepartmentController(DepartmentService ds, CollectionPointService cps, EmployeeService es)
 {
     this.ds  = ds;
     this.cps = cps;
     this.es  = es;
 }
        public ActionResult SaveOptions(DepartmentViewModel model)
        {
            departmentService      = new DepartmentService(context);
            collectionPointService = new CollectionPointService(context);
            userService            = new UserService(context);
            statusService          = new StatusService(context);
            delegationService      = new DelegationService(context);

            int        status     = 0;
            Department dpt        = departmentService.FindDepartmentByUser(userService.FindUserByEmail(CurrentUserName));
            Delegation delegation = new Delegation();

            dpt.UpdatedDateTime = DateTime.Now;
            dpt.UpdatedBy       = userService.FindUserByEmail(System.Web.HttpContext.Current.User.Identity.GetUserName());
            dpt.Representative  = userService.FindUserByEmail(model.DepartmentRep);
            dpt.CollectionPoint = collectionPointService.FindCollectionPointById(Convert.ToInt32(model.CollectionPoint));

            if (departmentService.Save(dpt) != null)
            {
                // Send notifications to all Store Clerks
                foreach (var user in new UserService(context).FindUsersByDepartment(departmentService.FindDepartmentByDepartmentCode("STOR")).Where(r => r.Roles.Select(ur => ur.RoleId).Contains("3")))
                {
                    var notification = new NotificationService(context).CreateChangeCollectionPointNotification(dpt, user);
                    new NotificationApiController()
                    {
                        context = context
                    }.SendNotification(notification.NotificationId.ToString());
                    new NotificationApiController()
                    {
                        context = context
                    }.SendEmail(notification.NotificationId.ToString());
                }
                status = 1;
            }

            delegation.Receipient = userService.FindUserByEmail(model.DelegationRecipient);

            if (delegation.Receipient != null && model.StartDate != null && model.EndDate != null)
            {
                delegation.DelegationId    = IdService.GetNewDelegationId(context);
                delegation.StartDate       = DateTime.Parse(model.StartDate, new CultureInfo("fr-FR", false));
                delegation.EndDate         = DateTime.Parse(model.EndDate, new CultureInfo("fr-FR", false));
                delegation.CreatedDateTime = DateTime.Now;
                //delegation.CreatedBy = user;
                delegation.CreatedBy = userService.FindUserByEmail(CurrentUserName);
                delegation.Status    = statusService.FindStatusByStatusId(1);
                delegationService.DelegateManager(delegation);
                status = 2;

                // Role
                //userService.AddDepartmentHeadRole(delegation.Receipient.Email);
            }

            if (delegation.Receipient != null && model.StartDate == null && model.EndDate == null)
            {
                status = 3;
            }

            return(new JsonResult {
                Data = new { status = status }
            });
        }
예제 #12
0
 public DashboardAPIController(DashboardService dashservice, EmployeeService empService, CollectionPointService cpService)
 {
     this.dashservice = dashservice;
     this.empService  = empService;
     this.cpService   = cpService;
 }