public void UpdateDevice(Device t)
 {
     using (IDataContext ctx = DataContext.Instance())
     {
         var rep = ctx.GetRepository<Device>();
         rep.Update(t);
     }
 }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            var t = new Device();
            var tc = new DeviceController();

            //TODO: populate device properties

            if (DeviceId > 0)
            {
                t = tc.GetDevice(DeviceId, ModuleId);
                t.DeviceName = txtName.Text.Trim();
                t.DeviceDescription = txtDescription.Text.Trim();
                t.LastModifiedByUserId = UserId;
                t.LastModifiedOnDate = DateTime.Now;
                
            }
            else
            {
                t = new Device()
                {
                    CreatedByUserId = UserId,
                    CreatedOnDate = DateTime.Now,
                    DeviceName = txtName.Text.Trim(),
                    DeviceDescription = txtDescription.Text.Trim(),

                };
            }

            t.LastModifiedOnDate = DateTime.Now;
            t.LastModifiedByUserId = UserId;
            t.ModuleId = ModuleId;

            if (t.Id > 0)
            {
                tc.UpdateDevice(t);
            }
            else
            {
                tc.CreateDevice(t);
            }
            Response.Redirect(DotNetNuke.Common.Globals.NavigateURL());
        }