public bool insertSale() { string eventIdStr = Request.Form["eventId"]; string ssi = Request.Form["ssi"]; string amount = Request.Form["amount"]; string ssiDec = UseKardoEncryption.getDecipherString(ssi); if (ssiDec == "KardoEncryptionError") { return(false); } int userId = Convert.ToInt32(UseKardoEncryption.getDecipherString(Session["KardoUserId"].ToString())); Dictionary <string, Object> theUser = DefaultModel.getUserFromUserId(userId); int eventId, ssId, amountInt; int kpId = (int)theUser["kardoPassoId"]; bool isNumeric = int.TryParse(eventIdStr, out eventId); bool isNumeric2 = int.TryParse(ssiDec, out ssId); bool isNumeric3 = int.TryParse(amount, out amountInt); if (isNumeric && isNumeric2 && isNumeric3) { return(EventDetailModel.insertSale(eventId, ssId, kpId, amountInt, userId)); } return(false); }
public DefaultController(DefaultView myView, DefaultModel myModel) { this.myView = myView; this.myModel = myModel; myView.myController = this; }
public async Task Multiple() { DefaultModel received1 = null; CriticalModel received2 = null; PackageReader reader1 = new PackageReader(); PackageReader reader2 = new PackageReader(); reader1.On <DefaultModel>((sender, model) => received1 = model); reader1.On <CriticalModel>((sender, model) => received2 = model); TestServer server = new TestServer(44352); server.Run(reader1, reader2); TwinoWebSocket client = new TwinoWebSocket(); client.Connect("127.0.0.1", 44352, false); client.Send(new DefaultModel { Name = "Default", Number = 501 }); client.Send(new CriticalModel { Name = "Critical", Number = 502 }); //wait for async package reading await Task.Delay(2000); Assert.NotNull(received1); Assert.Equal(501, received1.Number); Assert.NotNull(received2); Assert.Equal(502, received2.Number); }
public bool RolTienePermiso(string nombrePermiso, string userId) { var permiso = new DefaultModel(); try { using (var ctx = new ApplicationDbContext()) { permiso = ( from aur in ctx.ApplicationUserRoles.Where(x => x.UserId == userId) from srp in ctx.SegRolesPermisos.Where(x => x.RolId == aur.RoleId) from sper in ctx.SegPermisos.Where(x => x.Id == srp.PermisoId && x.Sigla == nombrePermiso) select new DefaultModel { Id = sper.Id } ).FirstOrDefault() ; if (permiso != null) { return(true); } else { return(false); } } } catch (Exception e) { Console.WriteLine(e.Message); return(false); } }
/// <summary> /// Create the default response. /// </summary> /// <param name="response">The response data.</param> /// <param name="queryString">The query string.</param> /// <param name="data">The default data.</param> /// <param name="exception">Should the exception response be processed.</param> /// <returns>The response.</returns> /// <exception cref="System.Exception"></exception> public static string CreateDefaultResponse(WebResponse response, NameValueCollection queryString, string data = "", Exception exception = null) { // Create the default response. DefaultModel defaultModel = new DefaultModel() { Data = data }; // Assign the body. response.Body = ResponseBody <DefaultModel>(defaultModel, queryString); // If no exception. if (exception == null) { // Return the default. return(Response <DefaultModel>(response, defaultModel, queryString)); } else { // Assign the error. response.Name = "error"; response.ReturnCode = -1; response.ErrorMessage = "Data format error. " + exception.Message; // Return the default. return(Response <DefaultModel>(response, defaultModel, queryString)); } }
public IActionResult Edit(string ID) { DefaultModel model = new DefaultModel { ID = ID }; ViewBag.Title = "Chỉnh sửa"; if (string.IsNullOrEmpty(ID)) { return(RedirectToAction("Create")); } else { var item = _service.GetByID(ID); if (item == null) { SetMessageError("Không tìm thấy đối tượng"); } ViewBag.Data = item; } ViewBag.Model = model; return(View()); }
public IActionResult Edit(int ID) { DefaultModel model = new DefaultModel { ID = ID }; ViewBag.Title = "Chỉnh sửa"; if (ID == 0) { return(RedirectToAction("Create")); } else { var item = _service.GetItemByID(ID); if (item == null) { ViewBag.Message = "Not Found Data"; } ViewBag.Data = item; } ViewBag.RoleData = _listRoles; ViewBag.Model = model; return(View()); }
public async Task <IActionResult> Create(DefaultModel model, CPMenuEntity item) { ViewBag.Title = "Thêm mới"; if (model.ID > 0 || item.ID > 0) { return(RedirectToAction("Edit", new { model.ID })); } else { if (item.ParentID > 0) { var root = _service.GetItemByID(item.ParentID); if (root != null) { item.Type = root.Type; } } item.LangID = _currentLang.ID; item.Code = UnicodeName.ConvertUnicodeToCode(item.Name, "-", true); await _service.SaveAsync(item); } ViewBag.Root = _service.CreateQuery().Find(o => o.ParentID == 0 && o.Activity == true) .Where(_currentLang != null, o => o.LangID == _currentLang.ID).ToList(); return(View()); }
public ActionResult Index(DefaultModel model) { System.IO.DirectoryInfo directoryInfo = new System.IO.DirectoryInfo(_environment.ContentRootPath + "\\Views\\Shared"); ViewBag.Data = null; ViewBag.Model = model; return(View()); }
public async Task UpdateDataById() { //Arrange var data = new List <DefaultModel>() { new DefaultModel { Id = Guid.NewGuid(), Field1 = "default", Field2 = 1, Field3 = "default2", Field4 = 2 }, new DefaultModel { Id = Guid.NewGuid(), Field1 = "default", Field2 = 2, Field3 = "default2", Field4 = 3 } }; var dbSet = NSubstituteUtils.CreateMockDbSet(data); var context = Substitute.For <DefaultContext>(); context.DefaultModels = dbSet; var controller = new DefaultController(context); var newValue = new DefaultModel { Id = data[0].Id, Field1 = "default", Field2 = 5, Field3 = "default2", Field4 = 7 }; //Act var result = await controller.UpdateDataByIdAsync(newValue); //Assert Assert.IsInstanceOf(typeof(NoContentResult), result); dbSet.Received(1).Update(Arg.Any <DefaultModel>()); await context.Received(1).SaveChangesAsync(); }
private void QueueActionWithCharacter( AbilityData i_dataAbility, DefaultModel i_model ) { // create the queued action and add it to our queue QueuedAction action = new QueuedAction( i_model, i_dataAbility ); m_queueActions.Enqueue( action ); // Debug.Log( i_dataCharacter.Name + " is queuing " + i_dataAbility.Name ); }
public IActionResult SubscribeAll(DefaultModel model) { foreach (var robot in Data.Data.Robots) { if (robot.Active) { try { if (Request.IsHttps) { robot.Subscribe("https://" + Request.Host.Value); } else { robot.Subscribe("http://" + Request.Host.Value); } } catch (Exception ex) { return(View("Index", new DefaultModel() { Information = $"Unable to subscribe events from the robot {robot.SerialNumber}. {ex.Message}", InformationClass = "red-text" })); } } } return(View("Index", new DefaultModel() { Information = "All robots subscribed to get data", InformationClass = "green-text" })); }
public IActionResult Edit(string ID) { DefaultModel model = new DefaultModel { ID = ID }; ViewBag.Title = "Cập nhật thông tin"; if (string.IsNullOrEmpty(ID)) { return(RedirectToAction("Create")); } else { var item = _service.GetByID(ID); var subjectdata = _subjectService.Find(true, o => o.IsActive).OrderBy(o => o.Name).ToList(); ViewBag.SubjectData = subjectdata; var gradedata = _gradeService.Find(true, o => o.IsActive).OrderBy(o => o.Name).ToList(); ViewBag.GradeData = gradedata; if (item == null) { SetMessageError("Không tìm thấy đối tượng"); } ViewBag.Data = item; } return(View()); }
public async Task <IActionResult> Create(DefaultModel model, ModGradeEntity item) { ViewBag.Title = "Thêm mới"; if (!string.IsNullOrEmpty(model.ID) || !string.IsNullOrEmpty(item.ID)) { return(RedirectToAction("Edit", new { model.ID })); } else { if (string.IsNullOrEmpty(item.Name)) { ViewBag.Message = "Bạn chưa điện tên của nhóm"; return(View()); } else { item.Code = UnicodeName.ConvertUnicodeToCode(item.Name, "-", true); if (_service.GetItemByCode(item.Code) == null) { await _service.AddAsync(item); ViewBag.Message = "Thêm thành công"; } else { ViewBag.Message = "Nhóm người đã tồn tại"; return(View()); } } } return(View()); }
public IActionResult Edit(string ID) { DefaultModel model = new DefaultModel { ID = ID }; ViewBag.Title = "Chỉnh sửa"; if (string.IsNullOrEmpty(ID)) { return(RedirectToAction("Create")); } else { var item = _service.GetByID(ID); if (item == null) { ViewBag.Message = "Not Found Data"; } else { ViewBag.Data = item; } } ViewBag.Model = model; return(View()); }
public async Task UpdateDataById_NotFoundError() { //Arrange var data = new List <DefaultModel>() { new DefaultModel { Id = Guid.NewGuid(), Field1 = "default", Field2 = 1, Field3 = "default2", Field4 = 2 }, new DefaultModel { Id = Guid.NewGuid(), Field1 = "default", Field2 = 2, Field3 = "default2", Field4 = 3 } }; var dbSet = NSubstituteUtils.CreateMockDbSet(data); var context = Substitute.For <DefaultContext>(); context.DefaultModels = dbSet; var controller = new DefaultController(context); var newValue = new DefaultModel { Id = Guid.NewGuid(), Field1 = "default", Field2 = 5, Field3 = "default2", Field4 = 7 }; //Act var result = await controller.UpdateDataByIdAsync(newValue); //Assert Assert.IsInstanceOf(typeof(NotFoundResult), result); }
public async Task <IActionResult> Edit(DefaultModel model, SysLang item) { ViewBag.Title = "Chỉnh sửa"; if (model.ID <= 0 && item.ID <= 0) { ViewBag.Message = "Chưa chọn đối tượng đê sửa"; } else { int ID = model.ID > 0 ? model.ID : item.ID; var _item = _service.GetItemByID(ID); item.ID = _item.ID; if (string.IsNullOrEmpty(item.Name)) { item.Name = _item.Name; } if (string.IsNullOrEmpty(item.Code)) { item.Code = _item.Code; } await _service.InsertItemAsync(item); ViewBag.Data = _service.GetItemByID(ID); } ViewBag.Model = model; return(RedirectToAction("index")); }
public void Single() { DefaultModel received = null; PackageReader reader = new PackageReader(); reader.On <DefaultModel>((sender, model) => received = model); TestServer server = new TestServer(44351); server.Run(reader); System.Threading.Thread.Sleep(250); TwinoWebSocket client = new TwinoWebSocket(); client.Connect("127.0.0.1", 44351, false); client.Send(new DefaultModel { Name = "Mehmet", Number = 500 }); //wait for async package reading System.Threading.Thread.Sleep(2000); Assert.NotNull(received); Assert.Equal(500, received.Number); }
public ActionResult Index(DefaultModel model) { model.PageInfo.PageSize = 7; model.PageInfo.Count = TblMessageDAO.QueryCount(); model.Messages = TblMessageDAO.Query(model.PageInfo); return(View(model)); }
public ActionResult Register() { DefaultModel df = new DefaultModel(); df.Name = "ABC"; return(View("AAA", df)); }
public async Task <IActionResult> Edit(DefaultModel model, CPUserEntity item) { ViewBag.Title = "Chỉnh sửa"; if (string.IsNullOrEmpty(model.ID) && string.IsNullOrEmpty(item.ID)) { ViewBag.Message = "Chưa chọn đối tượng đê sửa"; } else { string ID = model.ID; var _item = _service.GetByID(ID); item.ID = _item.ID; item.Email = _item.Email; item.Created = _item.Created > DateTime.MinValue ? _item.Created : DateTime.Now; if (item.Pass != _item.Pass) { item.Pass = Security.Encrypt(item.Pass); } await _service.AddAsync(item); ViewBag.Data = _service.GetByID(ID); } ViewBag.Model = model; ViewBag.RoleData = _listRoles; return(RedirectToAction("index")); }
public async Task <IActionResult> Edit(DefaultModel model, ModGradeEntity item) { ViewBag.Title = "Chỉnh sửa"; if (string.IsNullOrEmpty(model.ID) && string.IsNullOrEmpty(item.ID)) { ViewBag.Message = "Chưa chọn đối tượng đê sửa"; } else { string ID = !string.IsNullOrEmpty(model.ID) ? model.ID : item.ID; var _item = _service.GetByID(ID); item.ID = _item.ID; if (string.IsNullOrEmpty(item.Name)) { item.Name = _item.Name; } if (string.IsNullOrEmpty(item.Code)) { item.Code = UnicodeName.ConvertUnicodeToCode(item.Name, "-", true); } await _service.AddAsync(item); ViewBag.Data = _service.GetByID(ID); } ViewBag.Model = model; return(RedirectToAction("index")); }
public async Task <IActionResult> Create(DefaultModel model, CPMenuEntity item) { ViewBag.Title = "Thêm mới"; if (!string.IsNullOrEmpty(model.ID) || !string.IsNullOrEmpty(item.ID)) { return(RedirectToAction("Edit", new { model.ID })); } else { if (!item.ParentID.Equals("0")) { var root = _service.GetByID(item.ParentID); if (root != null) { item.Type = root.Type; } } item.LangID = _currentLang.ID; item.Code = UnicodeName.ConvertUnicodeToCode(item.Name, "-", true); await _service.AddAsync(item); } ViewBag.Root = _service.Find(true, o => o.ParentID.Equals("0") && o.IsActive == true) .Where(_currentLang != null, o => o.LangID == _currentLang.ID).ToList(); return(View()); }
public IActionResult Edit(string ID) { DefaultModel model = new DefaultModel { ID = ID }; ViewBag.Title = "Chỉnh sửa"; if (string.IsNullOrEmpty(ID)) { return(RedirectToAction("Create")); } else { var item = _service.GetByID(ID); if (item == null) { ViewBag.Message = "Not Found Data"; } ViewBag.Data = item; } ViewBag.Root = _service.CreateQuery().FindList(true, o => string.IsNullOrEmpty(o.ParentID) && o.IsActive == true) .Where(_currentLang != null, o => o.LangID == _currentLang.ID).ToList(); ViewBag.Model = model; return(View()); }
////////////////////////////////////////// /// QueueAction() /// Queues an action for whichever character /// is currently active. ////////////////////////////////////////// private void QueueAction(AbilityData i_dataAbility) { // char whose turn it is DefaultModel charCurrent = TurnManager.Instance.GetCurrentCharacter(); QueueActionWithCharacter(i_dataAbility, charCurrent); }
public async Task <IActionResult> Edit(DefaultModel model, CPMenuEntity item) { ViewBag.Title = "Chỉnh sửa"; if (string.IsNullOrEmpty(model.ID) && string.IsNullOrEmpty(item.ID)) { ViewBag.Message = "Chưa chọn đối tượng đê sửa"; } else { string ID = model.ID; var _item = _service.GetByID(ID); if (_item != null) { item.ID = _item.ID; item.Code = UnicodeName.ConvertUnicodeToCode(item.Name, "-", true); item.LangID = _currentLang.ID; await _service.AddAsync(item); } ViewBag.Data = _service.GetByID(ID); } ViewBag.Root = _service.CreateQuery().FindList(true, o => string.IsNullOrEmpty(o.ParentID) && o.IsActive == true) .Where(_currentLang != null, o => o.LangID == _currentLang.ID).ToList(); ViewBag.Model = model; return(RedirectToAction("index")); }
public ActionResult Index(DefaultModel model) { var results = new List <ModGradeViewModel>(); var data = _service .Find(!string.IsNullOrEmpty(model.SearchText), o => (o.Name.Contains(model.SearchText) || o.Code.Contains(model.SearchText))) .Where(o => o.CreateUser == _currentUser.ID) //.Where(!string.IsNullOrEmpty(model.ID), o => o.ID == model.ID) //.Where(string.IsNullOrEmpty(model.Record), o => (o.ParentID.Equals("0") || string.IsNullOrEmpty(o.ParentID))) .Where(!string.IsNullOrEmpty(model.Record), o => o.ParentID == model.Record) .OrderBy(o => o.Name) .ToList(); results.AddRange(data.Select(t => new ModGradeViewModel(t) { Parent = (string.IsNullOrEmpty(t.ParentID) || t.ParentID == "0") ? null : _service.GetByID(t.ParentID), SubGradeCount = _service.CountSubGradeByID(t.ID) })); ViewBag.Data = results.ToList(); model.TotalRecord = results.Count; ViewBag.Model = model; return(View()); }
public async Task <IActionResult> Edit(DefaultModel model, ModGradeEntity item) { ViewBag.Title = "Cập nhật thông tin"; if (string.IsNullOrEmpty(model.ID) && string.IsNullOrEmpty(item.ID)) { SetMessageWarning("Chưa chọn đối tượng chỉnh sửa"); } else { string ID = !string.IsNullOrEmpty(model.ID) ? model.ID : item.ID; var _item = _service.GetByID(ID); if (!string.IsNullOrEmpty(item.Name)) { _item.Name = item.Name; } _item.Updated = DateTime.Now; //TODO: tính toán xem có cần cập nhật lại code ko _item.ParentID = item.ParentID; _item.IsActive = item.IsActive; await _service.AddAsync(_item); ViewBag.Root = _service.GetRootItems(); ViewBag.Data = _service.GetByID(ID); SetMessageSuccess("Cập nhật thành công"); } ViewBag.Model = model; return(RedirectToAction("index")); }
public async Task <IActionResult> Delete(DefaultModel model) { int delete = 0; if (string.IsNullOrEmpty(model.ArrID)) { SetMessageError("Dữ liệu trống"); return(RedirectToAction("index")); } else { var arr = model.ArrID.Split(',').ToList(); int arrCount = arr != null ? arr.Count : 0; for (int i = 0; i < arrCount; i++) { string ID = arr[i]; var item = _service.GetByID(ID); await _service.RemoveAsync(item.ID); delete++; } if (delete > 0) { SetMessageSuccess("Đã xóa " + delete + " đối tượng"); return(RedirectToAction("Index")); } else { SetMessageWarning("Không có đổi tượng nào bị xóa"); return(RedirectToAction("Index")); } } }
public DefaultsViewModel() { selectDefault = new DefaultModel(); selectDefault.DEFAULT_NOMINAL_CODE = "4000"; selectDefault.DEFAULT_TAX_CODE = "T1 14.00"; selectDefault.CURRENCY_CODE = "4000"; selectDefault.DEPARTMENT = "4000"; }
public async Task<ActionResult<string>> postForm([FromBody] DefaultModel defaultModel) { string response = await _fachadaUI.GenerarHTML(defaultModel); response += await _fachadaUI.GenerarScript(defaultModel); response += await _fachadaUI.GenerarCSS(); return response; }
public DefaultModel GetUser() { DefaultModel user = new DefaultModel() { UserName = Environment.UserName, UserDomainName = Environment.UserDomainName, MachineName = Environment.MachineName, OSVersionString = Environment.OSVersion.VersionString }; return user; }
////////////////////////////////////////// /// SetModel() /// Sets the model that this view is for. ////////////////////////////////////////// public void SetModel( DefaultModel i_model ) { // null check for safety ModelToView = i_model; if ( i_model == null ) { Debug.LogError( "PropertyView has null model: " + PropertyName ); } // if the model doesn't have the property, we want to create it bool bHas = ModelToView.HasProperty( PropertyName ); if ( bHas == false ) ModelToView.CreateProperty( PropertyName ); // get and save the property's guid for message listening Property property = ModelToView.GetProperty( PropertyName ); System.Guid guid = property.GetID(); SetPropertyID( guid, !bHas ); }
public QueuedAction( DefaultModel i_char, AbilityData i_ability ) { m_strCharacterID = i_char.GetPropertyValue<string>( "Name" ); m_dataAbility = i_ability; }
public string Default(DefaultModel model) { return "welcome to the default view"; }