コード例 #1
0
        public IHttpActionResult PutCalcRelease(int id, CalcRelease calcRelease)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            CalcRelease CalcReleaseFind = db.CalcRelease.FirstOrDefault(i => i.CalcID == id);

            CalcReleaseFind.User            = HttpContext.Current.User.Identity.Name.ToString();
            CalcReleaseFind.UpdateDate      = DateTime.Now;
            CalcReleaseFind.Configuration   = calcRelease.Configuration;
            CalcReleaseFind.Version         = calcRelease.Version;
            db.Entry(CalcReleaseFind).State = EntityState.Modified;

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #2
0
        public IHttpActionResult DeleteCalcRelease(int id)
        {
            CalcRelease calcRelease = db.CalcRelease.Find(id);

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

            db.CalcRelease.Remove(calcRelease);
            db.SaveChanges();

            return(Ok(calcRelease));
        }
コード例 #3
0
        public IHttpActionResult PostCalcRelease(CalcRelease calcRelease)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            calcRelease.CalcID        = calcRelease.ID;
            calcRelease.Configuration = Convert.ToString(calcRelease.Configuration);
            calcRelease.User          = HttpContext.Current.User.Identity.Name.ToString();
            calcRelease.UpdateDate    = DateTime.Now;

            db.CalcRelease.Add(calcRelease);
            db.SaveChanges();

            return(Ok(calcRelease));
        }
コード例 #4
0
        public HttpResponseMessage SetConfig(int id, JObject config)
        {
            dynamic     json = config;
            CalcRelease calcConfiguration = db.CalcRelease.Find(id);

            //Update the model with configuration and update information
            calcConfiguration.Configuration = Convert.ToString(json.data);
            calcConfiguration.User          = HttpContext.Current.User.Identity.Name.ToString();
            calcConfiguration.UpdateDate    = DateTime.Now;
            //update the database entity
            db.Entry(calcConfiguration).State = EntityState.Modified;
            db.SaveChanges();
            var response = Request.CreateResponse();

            response.Content = new StringContent(JsonConvert.SerializeObject(json.data));
            return(response);
        }
コード例 #5
0
 // GET: Calculation/CalcReleasePage
 public ActionResult Form(int?id)
 {
     if (Request.IsAuthenticated)
     {
         CalcRelease ProjectBoard = db.CalcRelease.Find(id);
         try
         {
             ViewData["SchemeName"] = ProjectBoard.Scheme;
             ViewData["CalcName"]   = ProjectBoard.Name;
         }
         catch
         {
         }
         return(View());
     }
     else
     {
         return(RedirectToAction("Login", "Account", new { area = "" }));
     }
 }
コード例 #6
0
        public HttpResponseMessage Get(int?id)
        {
            var         response          = Request.CreateResponse();
            CalcRelease calcConfiguration = db.CalcRelease.Find(id);

            if (calcConfiguration == null)
            {
                List <CategoryViewModel> json = repo.GetConfig(null);
                response.Content = new StringContent(JsonConvert.SerializeObject(json));
            }
            else
            {
                if (calcConfiguration.Configuration == null)
                {
                    List <CategoryViewModel> json = repo.GetConfig(null);
                    response.Content = new StringContent(JsonConvert.SerializeObject(json));
                }
                else
                {
                    response.Content = new StringContent(calcConfiguration.Configuration);
                }
            }
            return(response);
        }