public async Task ActionBegin(ActionEventArgs <TipoArea> args) { if (args.RequestType == Syncfusion.Blazor.Grids.Action.Save) { HttpResponseMessage response; bool found = tipoareas.Any(p => p.CG_TIPOAREA == args.Data.CG_TIPOAREA); TipoArea ur = new TipoArea(); if (!found) { args.Data.CG_CIA = 1; args.Data.USUARIO = "User"; response = await Http.PostAsJsonAsync("api/TipoArea", args.Data); args.Data.CG_TIPOAREA = tipoareas.Max(s => s.CG_TIPOAREA) + 1; } else { response = await Http.PutAsJsonAsync($"api/TipoArea/{args.Data.CG_TIPOAREA}", args.Data); } if (response.StatusCode == System.Net.HttpStatusCode.Created) { } } if (args.RequestType == Syncfusion.Blazor.Grids.Action.Delete) { await EliminarTipoDeArea(args); } }
public Area(int idArea, string nome, string documento, string telefone, string email, string observacoes, TipoArea tipoArea) { IdArea = idArea; Nome = nome; Documento = documento; Telefone = telefone; Email = email; Observacoes = observacoes; TipoArea = tipoArea; }
public async Task Create(TipoArea model) { try { _db.tipoArea.Add(model); await _db.SaveChangesAsync(); } catch (Exception e) { throw new Exception(e.Message, e); } }
public async Task Update(TipoArea model) { try { var _model = await _db.tipoArea.FirstOrDefaultAsync(e => e.TipoAreaId == model.TipoAreaId); if (_model != null) { _db.Entry(_model).CurrentValues.SetValues(model); await _db.SaveChangesAsync(); } } catch (Exception e) { throw new Exception(e.Message, e); } }
public async Task UpdateEstado(TipoArea obj) { try { var _obj = await _db.tipoArea.FirstOrDefaultAsync(e => e.TipoAreaId == obj.TipoAreaId); if (_obj != null) { _obj.Estado = obj.Estado; await _db.SaveChangesAsync(); } } catch (Exception e) { throw new Exception(e.Message, e); } }
public async Task ClickHandler(Syncfusion.Blazor.Navigations.ClickEventArgs args) { if (args.Item.Text == "Copy") { if (this.Grid.SelectedRecords.Count > 0) { foreach (TipoArea selectedRecord in this.Grid.SelectedRecords) { bool isConfirmed = await JsRuntime.InvokeAsync <bool>("confirm", "Seguro de que desea copiar el Tipo de Area?"); if (isConfirmed) { TipoArea Nuevo = new TipoArea(); Nuevo.DES_TIPOAREA = selectedRecord.DES_TIPOAREA; Nuevo.CG_CIA = 1; Nuevo.USUARIO = "User"; var response = await Http.PostAsJsonAsync("api/TipoArea", Nuevo); Nuevo.CG_TIPOAREA = tipoareas.Max(s => s.CG_TIPOAREA) + 1; if (response.StatusCode == System.Net.HttpStatusCode.Created) { Grid.Refresh(); var tipoarea = await response.Content.ReadFromJsonAsync <TipoArea>(); await InvokeAsync(StateHasChanged); Nuevo.CG_TIPOAREA = tipoarea.CG_TIPOAREA; tipoareas.Add(Nuevo); var itemsJson = JsonSerializer.Serialize(tipoarea); Console.WriteLine(itemsJson); //toastService.ShowToast($"Registrado Correctemente.Vale {StockGuardado.VALE}", TipoAlerta.Success); tipoareas.OrderByDescending(p => p.CG_TIPOAREA); } } } } Refresh(); } if (args.Item.Text == "Excel Export") { await this.Grid.ExcelExport(); } }
public bool Salvar(TipoAreaDTO dto) { if (dto == null) { throw new ArgumentNullException("dto"); } bool novoItem = false; var tipoArea = tipoAreaRepository.ObterPeloId(dto.Id); if (tipoArea == null) { tipoArea = new TipoArea(); novoItem = true; } tipoArea.Descricao = dto.Descricao; tipoArea.Automatico = dto.Automatico; if (Validator.IsValid(tipoArea, out validationErrors)) { if (novoItem) { tipoAreaRepository.Inserir(tipoArea); } else { tipoAreaRepository.Alterar(tipoArea); } tipoAreaRepository.UnitOfWork.Commit(); messageQueue.Add(Resource.Sigim.SuccessMessages.SalvoComSucesso, TypeMessage.Success); return(true); } else { messageQueue.AddRange(validationErrors, TypeMessage.Error); } return(false); }
public UsuarioLogadoViewModel ValidarLogin(LoginFormViewModel model, TipoArea area) { var login = ConversaoHelper.ToInt64(model.Login); var usuario = (from x in _usuarioRepository.Get() where x.Cpf == login select new { x.CargoId, FirstName = x.Nome, UserId = x.Id, x.Senha, x.DtInativacao, x.PerfilAcessoId }).FirstOrDefault(); if (usuario == null) { throw new Exception("Usuário não existe!"); } if (usuario.DtInativacao != null) { throw new Exception("Usuário inativo!"); } var senhaCriptografada = CriptografiaHelpers.Criptografar(model.Senha, model.Login); if (!usuario.Senha.SequenceEqual(senhaCriptografada)) { throw new Exception("Senha inválida!"); } return(new UsuarioLogadoViewModel { UserId = usuario.UserId, FirstName = usuario.FirstName, Roles = _permissaoApp.PermissoesString(usuario.PerfilAcessoId) }); }
public async Task <IHttpActionResult> UpdateEstado(TipoArea obj) { try { log.Info(new MDCSet(this.ControllerContext.RouteData)); await _repository.UpdateEstado(obj); return(Ok("Tipo de área actualizado correctamente!")); } catch (Exception e) { log.Error(new MDCSet(this.ControllerContext.RouteData), e); return(InternalServerError(e)); } }
[HttpPost][Authorize] public async Task <IHttpActionResult> Create(TipoArea obj) { try { log.Info(new MDCSet(this.ControllerContext.RouteData)); await _repository.Create(obj); return(Ok("Tipo de área creada correctamente!")); } catch (Exception e) { log.Error(new MDCSet(this.ControllerContext.RouteData), e); return(InternalServerError(e)); } }
private void Logar(IUsuarioApp usuarioApp, ILogApp logApp, LoginFormViewModel model, TipoArea area) { if (!ModelState.IsValid) { throw new Exception(Erro); } var usuario = usuarioApp.ValidarLogin(model, area); var log = new Log() { Action = "Login", Controller = "Login", UsuarioId = usuario.UserId, Ip = System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"], Area = area.ToString() }; logApp.SalvarLog(log); usuario.LogId = log.Id; var userData = JsonConvert.SerializeObject(usuario); var authTicket = new FormsAuthenticationTicket(1, usuario.UserId.ToString(), DateTime.Now, DateTime.Now.AddMinutes(30), false, userData); var encTicket = FormsAuthentication.Encrypt(authTicket); var faCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encTicket); Response.Cookies.Add(faCookie); }