示例#1
0
        public object ModifySectionHotSpotConfig([FromUri] int hotspotId, [FromBody] SectionHotSpotConfig config)
        {
            using (var entity = new SecureCloud_Entities())
            {
                var hotspot = entity.T_DIM_HOTSPOT_SECTION.FirstOrDefault(s => s.SpotId == hotspotId);
                if (hotspot == null)
                {
                    return(Request.CreateResponse(
                               System.Net.HttpStatusCode.BadRequest,
                               StringHelper.GetMessageString("截面热点不存在,修改失败")));
                }

                if (config.SectionId != default(int))
                {
                    hotspot.SectionId = config.SectionId;
                }
                if (config.SectionSpotX != default(decimal?))
                {
                    hotspot.Spot_X_Axis = config.SectionSpotX;
                }
                if (config.SectionSpotY != default(decimal?))
                {
                    hotspot.Spot_Y_Axis = config.SectionSpotY;
                }
                hotspot.SpotPath = config.SectionSpotPath == string.Empty ? null : config.SectionSpotPath;

                try
                {
                    entity.SaveChanges();
                    return(Request.CreateResponse(
                               System.Net.HttpStatusCode.Accepted,
                               new JObject(new JProperty("hotspotId", hotspotId)).ToString()));
                }
                catch (Exception ex)
                {
                    return(Request.CreateResponse(
                               System.Net.HttpStatusCode.BadRequest,
                               StringHelper.GetMessageString("修改截面热点失败")));
                }
            }
        }
示例#2
0
        public HttpResponseMessage AddSectionHotSpotConfig([FromBody] SectionHotSpotConfig config)
        {
            using (var entity = new SecureCloud_Entities())
            {
                var section = entity.T_DIM_SECTION.FirstOrDefault(s => s.SectionId == config.SectionId);
                if (section == null)
                {
                    return(Request.CreateResponse(
                               System.Net.HttpStatusCode.BadRequest,
                               StringHelper.GetMessageString("施工截面不存在,新增截面热点失败")));
                }

                var hotspot = new T_DIM_HOTSPOT_SECTION
                {
                    SectionId   = config.SectionId,
                    Spot_X_Axis = config.SectionSpotX, // xAxis
                    Spot_Y_Axis = config.SectionSpotY, // yAxis
                    SpotPath    = config.SectionSpotPath
                };

                var entry = entity.Entry(hotspot);
                entry.State = EntityState.Added;

                try
                {
                    entity.SaveChanges();
                    return(Request.CreateResponse(
                               System.Net.HttpStatusCode.Accepted,
                               new JObject(new JProperty("hotspotId", hotspot.SpotId)).ToString()));
                }
                catch (Exception ex)
                {
                    return(Request.CreateResponse(
                               System.Net.HttpStatusCode.BadRequest,
                               StringHelper.GetMessageString("新增施工截面热点失败")));
                }
            }
        }