public IHttpActionResult PutDutyGroup(int id, DutyGroup dutyGroup)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != dutyGroup.Id)
            {
                return(BadRequest());
            }

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

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DutyGroupExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public void Delete(int id)
        {
            DutyGroup DutyGroup = db.DutyGroup.Find(id);

            db.DutyGroup.Remove(DutyGroup);
            Save();
        }
        public IHttpActionResult GetDutyGroup(int id)
        {
            DutyGroup dutyGroup = db.DutyGroups.Find(id);

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

            return(Ok(dutyGroup));
        }
Beispiel #4
0
        private void SetCurrentDutyGroup(object dutyGroup)
        {
            DutyGroup dg = dutyGroup as DutyGroup;

            if (dg != null && _Provider.OngoingDuty != null)
            {
                //Todo: maybe put this logic to provider;
                _Provider.OngoingDuty.Group = dg;
                NotifyPropertyChanged(() => CurrentDutyGroup);
            }
        }
        public IHttpActionResult PostDutyGroup(DutyGroup dutyGroup)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.DutyGroups.Add(dutyGroup);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = dutyGroup.Id }, dutyGroup));
        }
        public IHttpActionResult DeleteDutyGroup(int id)
        {
            DutyGroup dutyGroup = db.DutyGroups.Find(id);

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

            db.DutyGroups.Remove(dutyGroup);
            db.SaveChanges();

            return(Ok(dutyGroup));
        }
 public void Update(DutyGroup obj)
 {
     db.Entry(obj).State = EntityState.Modified;
     Save();
 }
 public void Insert(DutyGroup obj)
 {
     db.DutyGroup.Add(obj);
     Save();
 }