protected void btnCreate_Click(object sender, EventArgs e) { string strName = txtClient.Text.Trim(); string strAum = txtAum.Text.Trim(); string strWebUrl = txtWebUrl.Text.Trim(); string strLogoUrl = txtLogo.Text.Trim(); string strRank = txtRank.Text.Trim(); bool boolIsActive = chkIsActive.Checked; Guid createdBy = Guid.NewGuid(); var proxy = new BusinessProxy(); if (Id != null) { EntityClient client = proxy.GetClient(Id); proxy.UpdateClient(client.Id.ToString(), strName, strAum, strWebUrl, strLogoUrl, strRank, boolIsActive); } else { proxy.CreateClient(strName, strAum, strWebUrl, strLogoUrl, strRank, boolIsActive, createdBy); } /* * txtClient.Text = ""; * txtAum.Text = ""; * txtWebUrl.Text = ""; * txtLogo.Text = ""; * txtRank.Text = ""; * chkIsActive.Checked = true;*/ Response.Redirect("clients.aspx"); }
public ODSCLIENTE Update(ODSCLIENTE model, EntityClient cliente) { var objRepository = new RepositoryClient(); EntityClient data = new EntityClient() { PK_ClientID = cliente.PK_ClientID, ClientID = model.IDCliente, FirstName = model.Nombrecliente, LastName = model.ApellidoCliente, StreetAddress = model.Calle, NumberExternalAddress = model.Numero, NumberInternalAddress = model.NumeroInterior, BoroughAddress = model.Colonia, MunicipalityAddress = model.Delegacion, PostalCodeAddress = model.CodigoPosta, AdditionalInfoAddress1 = model.Referencia1, AdditionalInfoAddress2 = model.Referencia2, AdditionalInfoAddress3 = model.Referencia3, AdditionalInfoAddress4 = model.Referencia4, AdditionalInfoAddress5 = model.Referencia5, PhoneNumber1 = model.CELULAR, PhoneNumber2 = model.TEL_CASA, PhoneNumber3 = model.TEL_TRABAJO, PhoneExtension1 = model.EXT_TRABAJO, Email = model.email, RCF = model.RFCCEDULA, Status = true, CreateDate = DateTime.UtcNow, ModifyDate = DateTime.UtcNow }; data = objRepository.Update(data); return(model); }
public async Task <IActionResult> Edit(int id, [Bind("Name,Id,Inn")] EntityClient entityClient) { if (id != entityClient.Id) { return(NotFound()); } if (ModelState.IsValid) { try { entityClient.SetUpdateDate(); _context.Update(entityClient); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EntityClientExists(entityClient.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(entityClient)); }
public AdminController(IConfigStore configStore, EntityClient entityClient, ILogger <AdminController> logger, DiscoveryClient discoveryClient) { ConfigStore = configStore; EntityClient = entityClient; Logger = logger; DiscoveryClient = discoveryClient; }
public async Task <IActionResult> Settings() { var config = await ConfigStore.GetConfigAsync(); try { if (TempData["check-settings"] is bool b && b) { // This doesn't check if the access token is valid... var inst = await DiscoveryClient.GetDiscoveryInfo(); // ... but this does. var entities = await EntityClient.GetEntities(); ViewBag.Instance = $"Home Assistant instance: <b>{inst.LocationName} (Version {inst.Version}) [{inst.BaseUrl}]</b>"; } } catch (Exception ex) { await ConfigStore.ManipulateConfig(c => c.Settings.AccessToken = c.Settings.BaseUri = null); config = await ConfigStore.GetConfigAsync(); TempData.Remove(AlertManager.GRP_SUCCESS); Logger.LogError(ex, "Invalid system settings entered, or unable to reach Home Assistant with the specified information."); TempData.AddError("The settings entered are not valid. HACC is unable to reach your Home Assistant instance. Try your entries again, consult the <a target=\"_blank\" href=\"https://github.com/qJake/HADotNet.CommandCenter/wiki/Initial-System-Setup\">setup guide</a> for help, or check the logs (console) for more information."); // Reloads the request showing the error (TempData doesn't commit until a reload). return(RedirectToAction("Settings")); } return(View(config.Settings)); }
/// <summary> /// Add or update a uom model /// </summary> /// <param name="model"></param> /// <param name="userName"></param> /// <returns></returns> public async Task <ViewResult <UomModel> > AddOrUpdate(UomModel model, string userName) { var result = new ViewResult <UomModel>(); try { using (var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { //check duplicated name // var dupUom = await _uomRepository.GetUomByName(model.Name, model.Id); var dupUom = await EntityClient.Uoms.Where(x => x.Name == model.Name && x.Id != model.Id && x.ExpireTime == null).FirstOrDefaultAsync(); if (dupUom != null) { result.Status = -2; result.Message = "Name is already taken"; return(result); } Uom uom; //new uom model if (model.Id == 0) { uom = model.ToUomModel(); uom.CreateTime = DateTime.UtcNow; uom.CreateBy = userName; } else { uom = await EntityClient.Uoms.Where(x => x.Id == model.Id && x.ExpireTime == null).FirstOrDefaultAsync(); if (uom == null) { result.Status = -3; result.Message = "UOM does not exist"; return(result); } uom.EditTime = DateTime.UtcNow; uom.EditBy = userName; uom.Name = model.Name; } // await _uomRepository.AddOrUpdate(uom); EntityClient.Uoms.AddOrUpdate(uom); await EntityClient.SaveChangesAsync(); result.Data = uom.ToUomModel(); scope.Complete(); } } catch (Exception ex) { result.Status = -1; result.Message = ex.Message; Logger.WriteErrorLog("UomService", "AddOrUpdate", ex); } return(result); }
public void GetClient(string Id) { var proxy = new BusinessProxy(); EntityClient client = proxy.GetClient(Id); txtClient.Text = client.Name; txtAum.Text = client.AUM; txtWebUrl.Text = client.WebURL; txtLogo.Text = client.LogoURL; txtRank.Text = client.Rank.ToString(); chkIsActive.Checked = client.IsActive; }
public async Task <IActionResult> Create([Bind("Name,Id,Inn")] EntityClient entityClient) { if (ModelState.IsValid) { entityClient.SetCreateDate(); entityClient.SetUpdateDate(); _context.Add(entityClient); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(entityClient)); }
public string Any(ClientInsertRequest request) { EntityClient client = new EntityClient { FirstName = request.FirstName, LastName = request.LastName, Address = request.Address, City = request.City, Country = request.Country, Zip = request.Zip, Email = request.eMail, Phone = request.Phone }; var result = Listing.Insert(client); //var result = Listing.Insert(request.Client); if (result == 0) { throw new HttpError(HttpStatusCode.NotFound, "food-not-found", "The requested food was not found in the listing."); } return(result.ToString()); }
/// <returns> /// 1 = Delete Success /// 0 = Delete Failed /// </returns> public Operate DeleteEmailTemplate(EmailTemplateModel model) { var existDao = EntityClient.EmailTemplates.Find(model.Id); if (existDao == null) { return new Operate { Status = 0 } } ; EntityClient.EmailTemplates.Remove(existDao); return(new Operate { Status = EntityClient.SaveChanges() > 0 ? 1 : 0 }); } }
/// <returns> /// 1 = Save Success /// 0 = Save Failed /// -1 = Subject already exist /// </returns> public ViewResult <EmailTemplateModel> SaveEmailTemplate(EmailTemplateModel model) { /* Update */ var existDao = EntityClient.EmailTemplates.Find(model.Id); if (existDao != null) { existDao.Subject = model.Subject; existDao.Body = model.Body; EntityClient.EmailTemplates.AddOrUpdate(existDao); EntityClient.SaveChanges(); return(new ViewResult <EmailTemplateModel> { Status = EntityClient.SaveChanges() > 0 ? 1 : 0, Data = model }); } ///* Exist Checking */ //if (EntityClient.EmailTemplates.Any(t => t.Subject == model.Subject)) //{ // return new ViewResult<EmailTemplateModel> // { // Status = -1, // Message = "Subject already exist" // }; //} /* Save New */ var newDao = new EmailTemplate { Subject = model.Subject, Body = model.Body }; EntityClient.EmailTemplates.Add(newDao); EntityClient.SaveChanges(); model.Id = newDao.Id; return(new ViewResult <EmailTemplateModel> { Status = EntityClient.SaveChanges() > 0 ? 1 : 0, Data = model }); }
/// <summary> /// Delete uom model /// NOTE: soft delete /// </summary> /// <param name="id"></param> /// <returns></returns> public async Task <Operate> DeleteById(int id) { var result = new Operate(); try { using (var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { // var uom = await _uomRepository.GetById(id); var uom = await EntityClient.Uoms.Where(x => x.Id == id && x.ExpireTime == null).FirstOrDefaultAsync(); if (uom == null) { result.Status = -2; result.Message = "Uom does not exist"; return(result); } var product = await EntityClient.Products.Where(x => x.UomId == id && x.ExpireTime == null).FirstOrDefaultAsync(); // var product = await _productRepository.GetProductByUomId(id); if (product != null) { result.Status = -3; result.Message = "Uom is used by product"; return(result); } // await _uomRepository.Delete(uom); uom.ExpireTime = DateTime.UtcNow; EntityClient.Uoms.AddOrUpdate(uom); await EntityClient.SaveChangesAsync(); scope.Complete(); } } catch (Exception ex) { result.Status = -1; result.Message = ex.Message; Logger.WriteErrorLog("UomService", "DeleteById", ex); } return(result); }
private void connect_Click(object sender, EventArgs e) { try { m_client = new EntityClient(agentAddress.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } connect.Enabled = false; // probe the client for devices var devices = m_client.Probe(); PopulateAgentTree(devices); }
public static ODSCLIENTE Update(ODSCLIENTE model, EntityClient cliente) { return(new BusinessClient().Update(model, cliente)); }
public int Insert(EntityClient client) { return(memberService.Insert(client)); }
public NavigationTileController(IConfigStore configStore, EntityClient entityClient) { ConfigStore = configStore; EntityClient = entityClient; }
public int Insert(EntityClient client) { object id = Connection.GetScalar <object>("User_Insert", client.FirstName, client.LastName, client.Address, client.City, client.Zip, client.Country, client.Email, client.Phone); return(int.Parse(id.ToString())); }
public AdminTileController(IConfigStore configStore, EntityClient entityClient, IHubContext <TileHub, ITileHub> hubContext) { ConfigStore = configStore; EntityClient = entityClient; TileHub = hubContext; }
public WeatherTileController(IConfigStore configStore, EntityClient entityClient) { ConfigStore = configStore; EntityClient = entityClient; }
public AdminController(IConfigStore configStore, EntityClient entityClient) { ConfigStore = configStore; EntityClient = entityClient; }
private void EntitiesAreSynchronized() { // Initialization RailClientRoom clientRoom = client.StartRoom(); RailServerRoom serverRoom = server.StartRoom(); EntityServer entityServerSide = serverRoom.AddNewEntity <EntityServer>(); server.AddClient(peerServerSide.Object, ""); client.SetPeer(peerClientSide.Object); // Nothing has been sent or received yet peerClientSide.Verify( c => c.SendPayload(It.IsAny <ArraySegment <byte> >()), Times.Never()); peerServerSide.Verify( c => c.SendPayload(It.IsAny <ArraySegment <byte> >()), Times.Never()); Assert.Empty(clientRoom.Entities); Assert.Single(serverRoom.Entities); // Let the server send its update to the client for (int i = 0; i < RailConfig.SERVER_SEND_RATE + RailConfig.CLIENT_SEND_RATE + 1; ++i) { peerServerSide.Object.PollEvents(); server.Update(); peerClientSide.Object.PollEvents(); client.Update(); } // The client has received the server entity. Assert.Single(clientRoom.Entities); Assert.Single(serverRoom.Entities); // Clients representation of the entity is identical to the server RailEntityBase entityProxy = clientRoom.Entities.First(); Assert.IsType <EntityClient>(entityProxy); EntityClient entityClientSide = entityProxy as EntityClient; Assert.NotNull(entityClientSide); Assert.Equal(entityServerSide.Id, entityProxy.Id); Assert.Equal(entityClientSide.State.PosX, entityServerSide.State.PosX); Assert.Equal(entityClientSide.State.PosY, entityServerSide.State.PosY); // Change the entity on the server side and sync it to the client float fExpectedPosX = 42; float fExpectedPosY = 106; entityServerSide.State.PosX = fExpectedPosX; entityServerSide.State.PosY = fExpectedPosY; // Let the server detect the change and send the packet server.Update(); bool bWasSendTick = serverRoom.Tick.IsSendTick(RailConfig.SERVER_SEND_RATE); while (!bWasSendTick) { server.Update(); bWasSendTick = serverRoom.Tick.IsSendTick(RailConfig.SERVER_SEND_RATE); } // Let the client receive & process the packet. We need to bring the client up to the same tick as the server to see the result. while (clientRoom.Tick < serverRoom.Tick) { peerClientSide.Object.PollEvents(); client.Update(); } Assert.Equal(fExpectedPosX, entityClientSide.State.PosX); Assert.Equal(fExpectedPosY, entityClientSide.State.PosY); Assert.Equal(fExpectedPosX, entityServerSide.State.PosX); Assert.Equal(fExpectedPosY, entityServerSide.State.PosY); }
public CalendarTileController(IConfigStore configStore, EntityClient entityClient) { ConfigStore = configStore; EntityClient = entityClient; }
public SceneTileController(IConfigStore configStore, EntityClient entityClient) { ConfigStore = configStore; EntityClient = entityClient; }
public int Insert(EntityClient client) { return(_membershipRepository.Insert(client)); }