public PrikormList Create(PrikormList prikormList)
        {
            if (prikormList != null)
            {
                db.PrikormLists.Add(prikormList);
                Save();
            }

            return(prikormList);
        }
        public PrikormList Update(PrikormList prikormList)
        {
            if (!db.PrikormLists.Any(x => x.Id == prikormList.Id))
            {
                return(null);
            }

            db.Update(prikormList);
            Save();
            return(prikormList);
        }
        public PrikormList Delete(int id)
        {
            PrikormList prikormList = db.PrikormLists.FirstOrDefault(x => x.Id == id);

            if (prikormList == null)
            {
                return(prikormList);
            }

            db.PrikormLists.Remove(prikormList);
            Save();
            return(prikormList);
        }
示例#4
0
        public ActionResult <PrikormList> Post(PrikormList prikormlist)
        {
            if (!ModelState.IsValid)
            {
                logger.Info("PrikormList ModelState is not valid.");
                return(BadRequest());
            }

            try
            {
                return(Ok(prikormlistRepository.Create(prikormlist)));
            }
            catch (Exception ex)
            {
                logger.Error(ex);
                return(BadRequest(ex));
            }
        }
示例#5
0
        public ActionResult <PrikormList> Delete(int id)
        {
            try
            {
                PrikormList prikormlist = prikormlistRepository.Delete(id);
                if (prikormlist == null)
                {
                    logger.Info("PrikormList is not found: " + id + ".");
                    return(NotFound());
                }

                return(NoContent());
            }
            catch (Exception ex)
            {
                logger.Error(ex);
                return(BadRequest(ex));
            }
        }
示例#6
0
        public async Task <ActionResult <PrikormList> > Get(int id)
        {
            try
            {
                PrikormList prikormlist = await prikormlistRepository.Get(id);

                if (prikormlist == null)
                {
                    logger.Info("PrikormList is not found: " + id + ".");
                    return(NotFound());
                }

                return(Ok(prikormlist));
            }
            catch (Exception ex)
            {
                logger.Error(ex);
                return(BadRequest(ex));
            }
        }