public AssignmentEditPage(int assignmentId, ModelUser user) { InitializeComponent(); IModelStore model = ((App)Application.Current).model; ModelAssignment assignment = user.getAssignemt(assignmentId); this.name_Entry.Text = assignment.name; this.description_Entry.Text = assignment.description; //DatePicker stuff this.datePicker.Date = assignment.dueDate; DateTime now = DateTime.Now; this.datePicker.Format = "d"; this.datePicker.MinimumDate = now; this.datePicker.MaximumDate = now.AddYears(1); //-------------------------------------- AssignmentEditPage_Controler controler = new AssignmentEditPage_Controler( name_Entry, datePicker, description_Entry, confirm_Button, this, assignmentId, user.id ); }
public async Task <string> execute() { Response response = await this.model.editAssignment( this.assignmentName, this.assignmentDueDate, this.assignmentDescription, this.isClosed, this.assignmentId, this.teacherId ); if (!response.isOk) { return(response.message); } ModelUser teacher = this.model.getItem <ModelUser>(DataKeys.getUserKey(this.teacherId)); ModelAssignment assignment = null; foreach (ModelAssignment ass in teacher.assignments) { if (ass.id == this.assignmentId) { assignment = ass; } } if (assignment == null) { return("Failure, assignment not on model"); } AssignmentFetchObject aFO = new AssignmentFetchObject(this.assignmentId, assignment.classRoomName, this.assignmentDueDate, this.assignmentDescription, this.isClosed, this.assignmentName ); ServerResponse serverResponse = await this.model.fetchDataBaseObject(aFO, ECmdObjType.assignmentFetchObj); if (!serverResponse.errorResponse.isOk) { return(serverResponse.errorResponse.message); } if (aFO.isSame(serverResponse.fetchObject)) { return("Success! \n" + aFO.render()); } else { return("Failure :("); } }
public void viewUpdated(EModelUpdateType updateType) { //Get data from Model ModelAssignment assignment = this.model.getItem <ModelUser>(this.getUserDataKey()).getAssignemt(assignmentId); this.name_Label.Text = assignment.name; this.dueDate_Label.Text = assignment.dueDate.ToString(); this.description_Label.Text = assignment.description; }
//-------------------Tool Methods------------------------------------- public DataItemUpdate makeDataItemUpdate(ModelUpdate modelUpdate) { EModelType modelType = (EModelType)modelUpdate.modelType; switch (modelType) { case EModelType.modelAssignemt: ModelAssignment assignment = JsonConvert.DeserializeObject <ModelAssignment>(modelUpdate.modelItemAsJson); return(new DataItemUpdate(modelUpdate.dataKey, assignment)); case EModelType.modelClassRoom: ModelClassRoom classRoom = JsonConvert.DeserializeObject <ModelClassRoom>(modelUpdate.modelItemAsJson); return(new DataItemUpdate(modelUpdate.dataKey, classRoom)); case EModelType.modelUser: ModelUser user = JsonConvert.DeserializeObject <ModelUser>(modelUpdate.modelItemAsJson); return(new DataItemUpdate(modelUpdate.dataKey, user)); } return(null); }
public async Task AddModelToAssignment(Model model, Assignment assignment) { var modelassignment = new ModelAssignment { AssignmentId = assignment.AssignmentId, ModelId = model.ModelId }; using (var database = new BereauDbContext(_context)) { await database.ModelAssignments.AddAsync(modelassignment); assignment.ModelsNeeded -= 1; if (assignment.ModelsNeeded == 0) { assignment.Planned = true; } database.Assignments.Update(assignment); await database.SaveChangesAsync(); } }