public ActionResult Create()
        {
            var meterGroup = new MeterGroup {
                IsNew = true
            };

            _meterGroupRepository.InsertAndCommit(meterGroup);
            return(Json(new { Id = meterGroup.Id }));
        }
Example #2
0
        private int AddMeterGroup(string address)
        {
            List <MeterGroup> remote = WebAPIHub.GetRecords(address, "MeterGroup", "all").Select(x => (MeterGroup)x).ToList();

            // if the company meter location does not exist, create it
            if (!remote.Where(x => x.Name == WebAPIHub.CompanyName).Any())
            {
                MeterGroup record = new MeterGroup()
                {
                    Name = WebAPIHub.CompanyName
                };

                return(WebAPIHub.CreateRecord(address, "MeterGroup", JObject.FromObject(record)));
            }
            else
            {
                return(remote.Where(x => x.Name == WebAPIHub.CompanyName).First().ID);
            }
        }
Example #3
0
        public static MeterGroupData ToViewData(this MeterGroup node, CategoryDictionary suffix = CategoryDictionary.None)
        {
            //GroupBLL groupBLL = new GroupBLL();
            MeterBLL    meterBLL    = new MeterBLL();
            BuildingBLL buildingBLL = new BuildingBLL();

            if (node == null)
            {
                return(null);
            }
            return(new MeterGroupData()
            {
                Id = node.Id,
                GroupId = node.GroupId,
                MeterId = node.MeterId,
                BuildingId = node.BuildingId,
                Enable = node.Enable,
                //Group = (suffix & CategoryDictionary.Group) == CategoryDictionary.Group ? (node.Group == null ? groupBLL.Find(node.GroupId).ToViewData() : node.Group.ToViewData()) : null,
                Meter = (suffix & CategoryDictionary.Meter) == CategoryDictionary.Meter ? (node.Meter == null ? meterBLL.Find(node.MeterId).ToViewData() : node.Meter.ToViewData()) : null,
                Building = (suffix & CategoryDictionary.Building) == CategoryDictionary.Building ? (node.Building == null ? buildingBLL.Find(node.BuildingId).ToViewData() : node.Building.ToViewData()) : null,
            });
        }
Example #4
0
 public static MeterGroup ToEntity(this MeterGroupModel model, MeterGroup destination)
 {
     return(model.MapTo(destination));
 }
Example #5
0
 public static MeterGroupModel ToModel(this MeterGroup entity)
 {
     return(entity.MapTo <MeterGroup, MeterGroupModel>());
 }