//GET
        public ActionResult CreateInit()
        {
            var initViewModel = new ContractCreateInitViewModel();

            var currentUser = manager.FindById(User.Identity.GetUserId());

            string currentName   = currentUser.UserName.ToString();
            string currentUserId = currentUser.Id.ToString();

            ViewBag.OwnerName = currentUserId;

            string currentDepartmentName = UtilAugust.GetDepartmentsOfUser(currentName, db).Select(d => d.DepartmentName).FirstOrDefault();

            ViewBag.ClientSelect = new SelectList(db.Mandants, "Id", "MandantName");

            IQueryable <Mandant> currentClient = UtilAugust.GetClientOfDepartment(currentDepartmentName, db);
            string currentClientName           = currentClient.Select(c => c.MandantName).FirstOrDefault();

            ViewBag.CoordinatorId = new SelectList(UtilAugust.GetCoordinatorsFromClient(currentClientName, db), "Id", "UserName");
            ViewBag.ClientId      = new SelectList(db.Mandants, "Id", "MandantName");

            initViewModel.Coordinators = new SelectList(UtilAugust.GetCoordinatorsFromClient(currentClientName, db), "Id", "UserName");

            return(View(initViewModel));
        }
Esempio n. 2
0
        //David: multiLevel Contract creation

        // GET: Contract/Create/CreateInit
        public ActionResult CreateInit()
        {
            var currentUser = manager.FindById(User.Identity.GetUserId());

            string currentName = currentUser.UserName.ToString();

            ViewBag.OwnerName = currentName;

            string currentDepartmentName = UtilAugust.GetDepartmentsOfUser(currentName, db).Select(d => d.DepartmentName).FirstOrDefault();

            ViewBag.ClientSelect = new SelectList(db.Mandants, "Id", "MandantName");

            if (currentDepartmentName != null)
            {
                IQueryable <Mandant> currentClient = UtilAugust.GetClientOfDepartment(currentDepartmentName, db);
                string currentClientName           = currentClient.Select(c => c.MandantName).FirstOrDefault();

                if (currentClientName != null)
                {
                    ViewBag.CoordinatorId = new SelectList(UtilAugust.GetCoordinatorsFromClient(currentClientName, db), "Id", "UserName");
                }
            }
            else
            {
                ViewBag.CoordinatorId = new SelectList(new[] { "No Coordinator" });
            }
            ViewBag.ClientId = new SelectList(db.Mandants, "Id", "MandantName");

            return(View());
        }
Esempio n. 3
0
        public ActionResult CreateInit([Bind(Include = "Id,Description,OwnerId,CoordinatorId")] Contract contract, string submit)
        {
            var currentUser = manager.FindById(User.Identity.GetUserId());

            //set the user in the contracts table
            contract.OwnerId = currentUser.Id;


            if (ModelState.IsValid)
            {
                contract.ContractStatusId = 1; //1==incomplete
                db.Contracts.Add(contract);
                db.SaveChanges();

                //Decide which button was pressed...then redirect
                if (submit == continueBtn)
                {
                    return(RedirectToAction("CreateGeneral", new { id = contract.Id }));
                }

                else

                {
                    return(RedirectToAction("Index"));
                }
            }

            //David: Let Author explain the following code. NO COMMENTS!!
            // ????????????????????????????????????????????????????????????????????????????????

            string currentName = currentUser.UserName.ToString();

            ViewBag.OwnerName = currentName;

            string currentDepartmentName = UtilAugust.GetDepartmentsOfUser(currentName, db).Select(d => d.DepartmentName).FirstOrDefault();

            ViewBag.ClientSelect = new SelectList(db.Mandants, "Id", "MandantName");

            if (currentDepartmentName != null)
            {
                IQueryable <Mandant> currentClient = UtilAugust.GetClientOfDepartment(currentDepartmentName, db);
                string currentClientName           = currentClient.Select(c => c.MandantName).FirstOrDefault();

                if (currentClientName != null)
                {
                    ViewBag.CoordinatorId = new SelectList(UtilAugust.GetCoordinatorsFromClient(currentClientName, db), "Id", "UserName");
                }
            }
            else
            {
                ViewBag.CoordinatorId = new SelectList(new[] { "No Coordinator" });
            }
            ViewBag.ClientId = new SelectList(db.Mandants, "Id", "MandantName");

            // ????????????????????????????????????????????????????????????????????????????????
            return(RedirectToAction("CreateInit"));

            //Make the model available in other controllers
        }
Esempio n. 4
0
        public ActionResult Register()
        {
            //Ober: Addes Client and Department Field
            var clients = db.Mandants;

            ViewBag.Client = new SelectList(clients, "Id", "MandantName");
            var departments = UtilAugust.GetDepartmentsFromClient(clients.Select(c => c.MandantName).FirstOrDefault(), db);

            ViewBag.Department = new SelectList(departments, "Id", "DepartmentName");
            //Ober:end
            return(View());
        }
Esempio n. 5
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            var department = Request["DepartmentText"];

            if (ModelState.IsValid && department != "" && (!model.UserName.Contains("@")))
            {
                var user = new ApplicationUser {
                    UserName = model.UserName, Email = model.Email
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                //Ober: added Department to DU_Relation

                db.DU_Relations.AddOrUpdate(
                    p => p.UserID,
                    new DU_Relation {
                    UserID = user.Id, DepartmentID = db.Departments.Single(i => i.DepartmentName == department).Id
                }
                    );
                db.SaveChanges();
                //Ober:end
                if (result.Succeeded)
                {
                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    return(RedirectToAction("Index", "Home"));
                }
                AddErrors(result);
            }

            var clients = db.Mandants;

            ViewBag.Client = new SelectList(clients, "Id", "MandantName");
            var departments = UtilAugust.GetDepartmentsFromClient(clients.Select(c => c.MandantName).FirstOrDefault(), db);

            ViewBag.Department = new SelectList(departments, "Id", "DepartmentName");

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Esempio n. 6
0
        public ActionResult GetJsonDepartmentsFromClient(string client)
        {
            var data = new SelectList(UtilAugust.GetDepartmentsFromClient(client, db), "Id", "DepartmentName").ToList();

            return(Json(data));
        }
Esempio n. 7
0
        public ActionResult GetJsonDispatchersFromDepartment(string department)
        {
            var data = new SelectList(UtilAugust.GetDispatchersFromDepartment(department, db), "Id", "UserName").ToList();

            return(Json(data));
        }
Esempio n. 8
0
        public ActionResult GetJsonCoordinatorsFromClient(string client)
        {
            var data = new SelectList(UtilAugust.GetCoordinatorsFromClient(client, db), "Id", "UserName").ToList();

            return(Json(data));
        }