コード例 #1
0
        public async Task <ActionResult> AddType(DeviceAddTypeModel model)
        {
            try
            {
                if (model.Type != null)
                {
                    var       cont     = (iotContext)System.Web.HttpContext.Current.Session["iotcontext"];
                    string    domainId = DomainSession.GetContextDomain(this.HttpContext);
                    iotDomain domain   = cont.Domains.First(d => d.DomainName.Equals(domainId));
                    domain.DeviceTypes.Add(model.Type);
                    await cont.SaveChangesAsync();

                    model.Result = StatusResponseGenerator.GetAlertPanelWithMsgAndStat("Success.",
                                                                                       RequestStatus.Success);
                }
                else
                {
                    model.Result = StatusResponseGenerator.GetAlertPanelWithMsgAndStat("Error.", RequestStatus.Failure);
                }
            }
            catch (Exception e)
            {
                model.Result = StatusResponseGenerator.GetAlertPanelWithMsgAndStat("Error.", RequestStatus.Failure);
            }
            return(View(model));
        }
コード例 #2
0
        public ActionResult Edit(int Id)
        {
            var                cont     = (iotContext)System.Web.HttpContext.Current.Session["iotcontext"];
            string             domainId = DomainSession.GetContextDomain(this.HttpContext);
            iotDomain          domain   = cont.Domains.First(d => d.DomainName.Equals(domainId));
            var                type     = domain.DeviceTypes.FirstOrDefault(t => t.Id == Id);
            DeviceAddTypeModel model    = new DeviceAddTypeModel();

            model.Type = type;
            return(View(model));
        }
コード例 #3
0
        public ActionResult AddType()
        {
            DeviceAddTypeModel model = new DeviceAddTypeModel();

            return(View(model));
        }