Пример #1
0
        /// <summary>
        /// This save element method will use when one or more than one node add into the tree, parent element can not be null because this element can not be add into the root level (Physical point)
        /// </summary>
        /// <param name="parentId"></param>
        /// <param name="elementDto"></param>
        public void SaveElement(long parentId, IEnumerable <DiscoveryPoint_DTO> elementDto, long tagId)
        {
            //save only rows where Row_Type == point
            elementDto = elementDto.Where(element => element.Row_Type == DiscoverPoint_Type.Point);
            if (elementDto.Count() > 0)
            {
                IEnumerable <tblElement> list_elements = _dbcontext.tblElements.AddRange(DiscoveryPoint_DTO_Conversion.ConvertDTOToTable(elementDto, parentId, tagId));
                _dbcontext.SaveChanges();

                //This line for to create a metric when the element add into the structure list
                _metricRepository.Save_Metric(list_elements);
            }
        }
Пример #2
0
        public ActionResult Metric_Insert([DataSourceRequest] DataSourceRequest request, MetricDTO metric)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    _iMetricRepository.Save_Metric(metric);

                    return(Json(new[] { metric }.ToDataSourceResult(request, ModelState), JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(null, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }
        }