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)); }
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)); }
public ActionResult AddType() { DeviceAddTypeModel model = new DeviceAddTypeModel(); return(View(model)); }