Example #1
0
        public ActionResult <string> Get(int id)
        {
            ResponseModel model = new ResponseModel();

            try
            {
                if (id == 0)
                {
                    model.IsSuccess = false;
                    model.Message   = "Error: Id needs to be larger than 0";
                    return(JsonConvert.SerializeObject(model));
                }
                _log.LogInformation("Get Launch Pads " + id);
                PadModel pad = _manager.GetPad(id);

                model.IsSuccess = true;
                model.Item      = new LaunchPadModel(pad.Id, pad.Name, pad.Status) as object;

                _log.LogInformation("GOT Launch Pads " + id);

                return(JsonConvert.SerializeObject(model));
            }
            catch (Exception exception)
            {
                _log.LogError(exception, "Get Error: " + id);
                model.IsSuccess = false;
                model.Message   = "Error: Exception occurred, Error Logged. " + exception.Message;

                return(JsonConvert.SerializeObject(model));
            }
        }
        public IHttpActionResult PutPadModel(long id, PadModel padModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != padModel.ID)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult GetPadModel(long id)
        {
            PadModel padModel = db.Pads.Find(id);

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

            return(Ok(padModel));
        }
Example #4
0
        public PartialViewResult Partial_GetAllPads()
        {
            PadModel pad = new PadModel();
            //Get data from Db
            var allPadsDal = bll.BllGetAllDataTableFromDb(new Pads());

            //Map class on class - return List<1st parameter method>
            DataStorePlace.allPadsModel = helpMethod.HandMapper(new PadModel(), allPadsDal);
            //Here call a function for creating DropDownList
            pad.AllPadsFromDb = helpMethod.MakeDropDownList(DataStorePlace.allPadsModel);
            return(PartialView(pad));
        }
        public IHttpActionResult DeletePadModel(long id)
        {
            PadModel padModel = db.Pads.Find(id);

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

            db.Pads.Remove(padModel);
            db.SaveChanges();

            return(Ok(padModel));
        }
        public IHttpActionResult PostPadModel(PadModel padModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Pads.Add(padModel);
            db.SaveChanges();

            CreatedAtRoute("DefaultApi", new { id = padModel.ID }, padModel);

            return(Ok(padModel));
        }