Exemplo n.º 1
0
        public bool CreateAssignment(AssignmentCreate model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var employeeName  = ctx.Employees.Find(model.EmployeeId);
                var taskName      = ctx.Tasks.Find(model.TaskId);
                var taskSummary   = ctx.Tasks.Find(model.TaskId);
                var taskDueDate   = ctx.Tasks.Find(model.TaskId);
                var taskFlagged   = ctx.Tasks.Find(model.TaskId);
                var taskCompleted = ctx.Tasks.Find(model.TaskId);
                var entity        =

                    new Assignment()
                {
                    AssignmentOwnerId = _userId,
                    OwnerId           = _userId,
                    EmployeeId        = model.EmployeeId,
                    EmployeeFullName  = employeeName.EmployeeFullName,
                    TaskId            = model.TaskId,
                    TaskName          = taskName.TaskName,
                    TaskSummary       = taskSummary.TaskSummary,
                    DueDate           = taskDueDate.DueDate,
                    AssignerFirstName = model.AssignerFirstName,
                    AssignerLastName  = model.AssignerLastName,
                    DeptA             = model.DeptA,
                    AssignedDate      = DateTimeOffset.Now,
                    Flagged           = taskFlagged.Flagged,
                    Completed         = taskCompleted.Completed,
                };
                ctx.Assignments.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Exemplo n.º 2
0
        public bool CreateAssignment(AssignmentCreate model)
        {
            var entity = new Assignment()
            {
                ApplicationUserId   = _userid,
                CardId              = model.CardId,
                DeckId              = model.DeckId,
                NumberOfAssignments = 1
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Assignments.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Exemplo n.º 3
0
        public ActionResult Create(AssignmentCreate model)
        {
            //if (!ModelState.IsValid) return View(model);

            var service = CreateAssignmentService();

            if (service.CreateAssignment(model))
            {
                TempData["SaveResult"] = "The assignment was created successfully!";
                return(RedirectToAction("Index"));
            }
            ;

            //ModelState.AddModelError("", "The assignment could not be created!");
            return(View(model));
        }
        // CREATE
        public bool CreateAssignment(AssignmentCreate model)
        {
            var entity =
                new Assignment()
            {
                AssignmentRequest = model.AssignmentRequest,
                School            = model.School,
                SchoolID          = model.SchoolID,
                Scout             = model.Scout,
                ScoutID           = model.ScoutID
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Assignments.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
        public ActionResult Create(AssignmentCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = CreateAssignmentService();

            if (service.CreateAssignment(model))
            {
                TempData["SaveResult"] = "The assignment was added successfully.";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "There was an issue adding the assignment.");

            return(View(model));
        }
Exemplo n.º 6
0
        public bool AssignmentCreate(AssignmentCreate model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var userEntity =
                    ctx
                    .Users
                    .Single(u => u.UserName == model.UserName);

                var newAssignment = new Assignment()
                {
                    UserId    = userEntity.Id,
                    ProjectId = model.ProjectId,
                    TeamId    = model.TeamId
                };

                ctx.Assignments.Add(newAssignment);
                return(ctx.SaveChanges() == 1);
            }
        }
Exemplo n.º 7
0
        public IHttpActionResult Post(AssignmentCreate assignment)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreateAssignmentService();

            if (!service.AssignmentCreate(assignment))
            {
                return(InternalServerError());
            }

            string newLog     = "Assignment Created";
            var    logService = CreateLogService();

            logService.LogCreate(newLog);

            return(Ok(newLog));
        }
Exemplo n.º 8
0
        // Assignments
        public static List <AssignmentCreate> AssignmentDummyData()
        {
            List <AssignmentCreate> assignments = new List <AssignmentCreate>();

            var userName  = new string[] { "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**" };
            var teamId    = new int[] { 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 1, 1, 6, 6, 7, 1, 1, 1 };
            var projectId = new int[] { 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 6 };

            for (int i = 0; i < userName.Length; i++)
            {
                var assignment = new AssignmentCreate()
                {
                    UserName  = userName[i],
                    TeamId    = teamId[i],
                    ProjectId = projectId[i]
                };

                assignments.Add(assignment);
            }

            return(assignments);
        }
        // GET: Create
        public ActionResult CreateAssignment(int deckId, int cardId, bool isCard)
        {
            var svc = CreateAssignmentService();

            if (!svc.CheckAssignment(cardId, deckId))
            {
                var assignment = new AssignmentCreate()
                {
                    DeckId = deckId,
                    CardId = cardId
                };

                svc.CreateAssignment(assignment);
            }

            TempData["SaveResult"] = "Card Added to Deck";
            if (isCard)
            {
                return(RedirectToAction("Create", new { id = cardId, isCard = true }));
            }
            return(RedirectToAction("Create", new { id = deckId, isCard = false }));
        }