public void addAssignment(AssignmentViewModel newAssignment)
        {
            using (var context = new dbContext())
            {
                assignment model = new assignment
                {
                    name          = newAssignment.Name,
                    maxSubmisions = newAssignment.MaxSubmissions,
                    groupSize     = newAssignment.GroupSize,
                    startDate     = newAssignment.AssignmentStart,
                    endDate       = newAssignment.AssignmentEnd,
                    courseID      = newAssignment.CourseID
                };
                context.assignments.Add(model);
                context.SaveChanges();

                assignmentPart modelPart = new assignmentPart
                {
                    descriptoin  = newAssignment.Description,
                    solutionFile = newAssignment.SolutionFile,
                    assignmentID = model.ID
                };
                context.assignmentParts.Add(modelPart);
                context.SaveChanges();
            }
        }
        private void saveClick(object sender, RoutedEventArgs e)
        {
            assignment ass = new assignment(courseNameTb.Text, datePicker.SelectedDate.Value.Date, assNameTb.Text);

            vm.VM_AssignmentList.Add(ass);
            this.Close();
        }
Esempio n. 3
0
        //Passing Rejected(Assignment list) Status description method
        private async void UnavailableClicked(object sender, EventArgs e)
        {
            //Binding Item data
            var indigentDetails = (Indigents)BindingContext;
            //Fecting application Reference Number
            var applicationRefNo = indigentDetails.indigentApplicationDetails.indigentApplicationHeader.applicationRefNo;
            //Passing application Reference Number To PassAcceptedDetails method
            var getApplicationId = await passRejectedDetails(applicationRefNo);


            //DeserializeObject of Rejected status description
            var root = JsonConvert.DeserializeObject <Status>(getApplicationId);

            //check the status description
            if (root.StatusResponse.StatusDescription == "Success")
            {
                assignment assignment1      = new assignment();
                string     applicantDetails = Newtonsoft.Json.JsonConvert.SerializeObject(indigentDetails);
                assignment1.applicantDetails = applicantDetails;
                assignment1.fieldWorkerID    = indigentDetails.fieldWorkerID;
                assignment1.status           = "Rejected";
                assignment1._id = indigentDetails._id;

                await App.Database.SaveItemAsync(assignment1);
                await DisplayAlert("Status", "Saved SuccessFully", "Okay", "Cancel");

                //await DisplayAlert("Status", "Accepted", "Okay", "Cancel");
                await Navigation.PopAsync();
            }
            else
            {
                //display unsuccessfull message
                await DisplayAlert("Status", "Unsuccessfull", "Okay", "Cancel");
            }
        }
Esempio n. 4
0
        public void removeUserFromTask()
        {
            this.showAssignments();
            User user  = this.ChoseUser();
            Task task  = this.ChoseTask();
            bool check = assignments[task].TryGetValue(user.id, out User user1);

            if (check)
            {
                assignments[task].Remove(user.id);
                assignment new_assignment = new assignment();
                foreach (assignment tmp in this.db.assignments)
                {
                    if (tmp.taskName.Replace(" ", "") == task.name && tmp.userId == user.id)
                    {
                        new_assignment = tmp;
                    }
                }
                this.db.assignments.Remove(new_assignment);
                this.db.SaveChanges();
            }
            else
            {
                Console.WriteLine("there is no assignment with this information !!");
            }
        }
        public ActionResult Scoreboard(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            int            assignmentId = Convert.ToInt32(id);
            assignment     assign       = assignmentService.GetAssignmentById(assignmentId);
            List <team>    teams        = scoreboardService.GetTeamsOfAssignment(assignmentId);
            List <problem> probs        = problmService.GetProblemsOfAssignment(assignmentId);

            List <ProblemSuccessHolder> tableData = new List <ProblemSuccessHolder>();

            foreach (var team in teams)
            {
                List <bool> success = new List <bool>();
                foreach (var prob in probs)
                {
                    success.Add(scoreboardService.CheckIfDone(prob.id, team.id));
                }
                tableData.Add(new ProblemSuccessHolder {
                    name = team.name, success = success
                });
            }
            ScoreboardViewModel info = new ScoreboardViewModel {
                assignment = assign, probs = probs.Count, tableData = tableData
            };

            return(View(info));
        }
Esempio n. 6
0
        protected override async void OnAppearing()
        {
            base.OnAppearing();
            assignment indigentApplicationDetails = new assignment();
            Indigents  indigent = new Indigents();

                        // Reset the 'resume' id, since we just want to re-start here
                       ((App)App.Current).ResumeAtTodoId = -1;

            var myList = await App.Database.GetItemsNotDoneAsync("Accepted");

            ArrayList accepted1 = new ArrayList();

            for (int i = 0; i < myList.Count; i++)
            {
                                //accepted1.Add(myList[i].applicantDetails);

                                accepted1.Add(Newtonsoft.Json.JsonConvert.DeserializeObject <Indigents>(myList[i].applicantDetails));

                Console.WriteLine(accepted1);
                Console.WriteLine("Hello");
            }
            Console.WriteLine(accepted1);
            listView.ItemsSource = accepted1;
        }
Esempio n. 7
0
        public JsonResult GetAssignmentAsJSON(int?id)
        {
            // Here we gather all the info about the assignment with the id we passed into the function
            int        assignId = Convert.ToInt32(id);
            assignment assign   = assignmentService.GetAssignmentById(assignId);

            return(Json(new { name = assign.name, compose = assign.description, deadline = assign.deadline.ToString() }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 8
0
        public ActionResult DeleteConfirmed(int id)
        {
            assignment assignment = db.assignment.Find(id);

            db.assignment.Remove(assignment);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            //assignment assignment = db.assignments.Find(id);
            //db.assignments.Remove(assignment);
            //db.SaveChanges();
            assignment assignment = db.assignments.SingleOrDefault(a => a.assignment_id == id);

            db.Delete(assignment);
            return(RedirectToAction("Index"));
        }
 public IActionResult AddAssignment([FromBody] assignment assign)
 {
     if (assignmentRepo.AddAssignment(assign))
     {
         return(Ok($"Successfully added to assignment."));
     }
     else
     {
         return(BadRequest("This assignment already exists."));
     }
 }
 public Task <int> SaveItemAsync(assignment item)
 {
     if (item.ID != 0)
     {
         return(database.UpdateAsync(item));
     }
     else
     {
         return(database.InsertOrReplaceAsync(item));
     }
 }
Esempio n. 12
0
        public void SendAssignmentDescription(project rightproject, assignment rightassignment)
        {
            string assignmentdesc = rightassignment.description;
            string archive        = "false";

            if (rightproject.finished == true)
            {
                archive = "true";
            }

            Clients.Caller.insertAssignmentDescription(assignmentdesc, archive);
        }
Esempio n. 13
0
        public void CreateValid()
        {
            //arrange
            assignment test = new assignment {
                title = "Java assignment"
            };
            //act
            var actual = (RedirectToRouteResult)controller.Create(test);

            //assert
            Assert.AreEqual("Index", actual.RouteValues["action"]);
        }
        public ActionResult Edit([Bind(Include = "assignment_id,title,description,due_date,course_id")] assignment assignment)
        {
            if (ModelState.IsValid)
            {
                //db.Entry(assignment).State = EntityState.Modified;
                //db.SaveChanges();
                db.Save(assignment);
                return(RedirectToAction("Index"));
            }
            //ViewBag.course_id = new SelectList(db.courses, "course_id", "course_name", assignment.course_id);

            return(View("Edit", assignment));
        }
Esempio n. 15
0
        public void CreateInValid()
        {
            //arrange
            assignment test = new assignment {
                title = "Java assignment"
            };

            controller.ModelState.AddModelError("Id", "Unit Test");
            //act
            var actual = (ViewResult)controller.Create(test);

            //assert
            Assert.AreEqual("Create", actual.ViewName);
        }
 public static bool AddAssignment(assignment assign)
 {
     if (!Store2.ContainsKey(assign.assignmentId))
     {
         ID++;
         assign.assignmentId = ID;
         Store2.Add(assign.assignmentId, assign);
         return(true);
     }
     else
     {
         return(false);
     }
 }
        public ActionResult Create([Bind(Include = "assignment_id,title")] assignment assignment)
        {
            if (ModelState.IsValid)
            {
                //db.assignments.Add(assignment);
                //db.SaveChanges();
                db.Save(assignment);
                return(RedirectToAction("Index"));
            }


            // ViewBag.course_id = new SelectList(db.courses, "course_id", "course_name", assignment.course_id);
            return(View("Create", assignment));
        }
Esempio n. 18
0
        // GET: Assignments/Details/5
        public ActionResult Details(int?id)
        {
            //If we get and invalid id we send a Badrequest status code result instead of rendering the view
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            assignment assignment = db.assignment.Find(id);

            if (assignment == null)
            {
                return(HttpNotFound());
            }
            return(View(assignment));
        }
Esempio n. 19
0
        public JsonResult Create(FormCollection collection)
        {
            var date = DateTime.Parse(collection["deadline"]);

            date.ToString("{0:dd-MM-yy HH:mm:ss.fff}", CultureInfo.InvariantCulture);
            assignment newAssignment = new assignment {
                name = collection["name"], description = collection["compose"], deadline = date, courseId = Convert.ToInt32(collection["courseId"])
            };

            db.assignment.Add(newAssignment);
            db.SaveChanges();
            int assignId = db.assignment.Max(x => x.id);

            return(Json(new { status = "SuccessAdd", assignmentId = assignId }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 20
0
    public string addAssignment(assignment newAssign)
    {
        int      courseId       = newAssign.CourseId;
        int      assitype       = newAssign.Type;
        DateTime subDate        = newAssign.SubDate;
        string   assignmentName = newAssign.AssignmentName;
        var      context        = new courseExampleEntities();
        var      cmd            = context.Database.Connection.CreateCommand();

        cmd.CommandText = "insert  into courseExample.dbo.assignment (CourseId,AssignmentName,Type,SubDate) values(" + courseId + ",'" +
                          assignmentName + "','" + assitype + "','" + subDate + "')";
        context.Database.Connection.Open();
        var reader = cmd.ExecuteReader();

        context.Database.Connection.Close();
        return("The assignment added successfully");
    }
        // GET: assignments/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                // return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
                return(View("Error"));
            }
            // assignment assignment = db.assignments.Find(id);
            assignment assignment = db.assignments.SingleOrDefault(a => a.assignment_id == id);

            if (assignment == null)
            {
                //return HttpNotFound();
                return(View("Error"));
            }
            return(View(assignment));
        }
        // GET: assignments/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                // return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
                //return RedirectToAction("Index");
                return(View("Error"));
            }
            //assignment assignment = db.assignments.Find(id);
            assignment assignment = db.assignments.SingleOrDefault(a => a.course_id == id);

            if (assignment == null)
            {
                //return HttpNotFound();
                //return RedirectToAction("Index");
                return(View("Error"));
            }
            return(View("Details", assignment));
        }
Esempio n. 23
0
        public void Assign()
        {
            User user  = this.ChoseUser();
            Task task  = this.ChoseTask();
            bool check = assignments[task].TryGetValue(user.id, out User user1);

            if (check)
            {
                Console.WriteLine("task already assigned to this user !");
            }
            else
            {
                assignments[task].Add(user.id, user);
                assignment new_assignment = new assignment();
                new_assignment.taskName = task.name;
                new_assignment.userId   = user.id;
                this.db.assignments.Add(new_assignment);
                this.db.SaveChanges();
            }
        }
 public Task <int> DeleteItemAsync(assignment item)
 {
     return(database.DeleteAsync(item));
 }
Esempio n. 25
0
    protected int CreateNewAssignment()
    {
        string project_textid = Request.QueryString["Project"];
        int    project_id     = int.Parse(project_textid);

        string name         = txtAssignmentName.Text;
        string description  = txtAssignmentDescription.Text;
        string percent_done = "0";
        bool   finished     = false;

        DateTime duedate = calendarDueDate.SelectedDate;

        try
        {
            int emptyrow = 0;
            int addedrow = 0;

            // First check for any gaps in the number sequence inside the database
            for (int i = 0; i <= ctx.assignment.Count(); i++)
            {
                assignment compareAssignment = new assignment();
                var        checkAssignment   = ctx.assignment.Where(gr => gr.amt_id == i).FirstOrDefault();

                if (checkAssignment == compareAssignment)
                {
                    emptyrow = i;
                }
                else
                {
                    compareAssignment = checkAssignment;
                }
            }

            if (emptyrow == 0)
            {
                addedrow = ctx.assignment.Count() + 1;
            }
            else
            {
                addedrow = emptyrow;
            }

            var newassignment = new assignment
            {
                name                = name,
                description         = description,
                creation_date       = DateTime.Today,
                assignment_due_date = duedate,
                percent_done        = percent_done,
                finished            = finished,
                privacy             = 1,
                project_id          = project_id
            };

            var assignmentlist = ctx.assignment.ToList();

            if (assignmentlist != null)
            {
                int tagindex = 100;

                foreach (var assignment in assignmentlist)
                {
                    tagindex = (int)assignment.amt_tag + 1;
                }

                newassignment.amt_tag = tagindex;
            }
            else
            {
                newassignment.amt_tag = 100;
            }

            ctx.assignment.Add(newassignment);
            ctx.SaveChanges();

            return(newassignment.amt_id);
        }
        catch (Exception ex)
        {
            if (ex.InnerException != null)
            {
                lbmessages.Text = ex.InnerException.ToString();
            }
            else
            {
                lbmessages.Text = ex.Message;
            }

            return(-1);
        }
    }