Exemplo n.º 1
0
        public async Task <IHttpActionResult> PutTask(int id, ClassLibraryHotel.Task task)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != task.TaskId)
            {
                return(BadRequest());
            }

            db.Entry(task).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TaskExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
 private void TaskList_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     t                       = (Task)tasksList.SelectedItem;
     AddNotes.Text           = t.Note;
     AddInfo.Text            = t.Info;
     TaskType.SelectedIndex  = t.Type - 1;
     TaskState.SelectedIndex = t.State;
 }
 private void Reset()
 {
     AddNotes.Text           = "";
     AddInfo.Text            = "";
     TaskType.SelectedIndex  = -1;
     TaskState.SelectedIndex = -1;
     t = null;
     TTNS.Visibility = Visibility.Hidden;
 }
Exemplo n.º 4
0
        public async Task <IHttpActionResult> GetTask(int id)
        {
            ClassLibraryHotel.Task task = await db.Tasks.FindAsync(id);

            if (task == null)
            {
                return(NotFound());
            }

            return(Ok(task));
        }
Exemplo n.º 5
0
        public async Task <IHttpActionResult> PostTask(ClassLibraryHotel.Task task)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Tasks.Add(task);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = task.TaskId }, task));
        }
Exemplo n.º 6
0
        public async Task <IHttpActionResult> DeleteTask(int id)
        {
            ClassLibraryHotel.Task task = await db.Tasks.FindAsync(id);

            if (task == null)
            {
                return(NotFound());
            }

            db.Tasks.Remove(task);
            await db.SaveChangesAsync();

            return(Ok(task));
        }
        private void Submit_Click(object sender, RoutedEventArgs e)
        {
            String n         = AddNotes.Text;
            String i         = AddInfo.Text;
            int    taskType  = TaskType.SelectedIndex + 1;
            int    taskState = TaskState.SelectedIndex;

            if (taskState == -1)
            {
                taskState = 0;
            }

            if (taskType != 1 && taskType != 2)
            {
                TTNS.Visibility = Visibility.Visible;
            }
            else
            {
                if (t == null)
                {
                    t            = new ClassLibraryHotel.Task();
                    t.Note       = n;
                    t.Info       = i;
                    t.Type       = taskType;
                    t.State      = taskState;
                    t.Room       = r;
                    t.RoomRoomId = r.RoomId;

                    tasks.Add(t);
                    hcx.SaveChanges();
                    tasksList.DataContext = null;
                    tasksList.DataContext = r.Tasks;
                }
                else
                {
                    t.Note  = n;
                    t.Info  = i;
                    t.Type  = taskType;
                    t.State = taskState;
                    hcx.SaveChanges();
                    tasksList.DataContext = null;
                    tasksList.DataContext = r.Tasks;
                }

                Reset();

                //Må oppdatere viduet slik at nye tasks vises.
            }
        }