public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            WarehouseTransaction = await _context.WarehouseTransactions
                                   .Include(w => w.Company)
                                   .Include(w => w.FiscalPeriod)
                                   .Include(w => w.WarehouseItem)
                                   .Include(w => w.Section)
                                   .Include(w => w.TransWarehouseDocSeries)
                                   .Include(w => w.TransWarehouseDocType).FirstOrDefaultAsync(m => m.Id == id);

            if (WarehouseTransaction == null)
            {
                return(NotFound());
            }
            var section = _context.Sections.SingleOrDefault(s => s.SystemName == SectionSystemCode);

            if (section is null)
            {
                _toastNotification.AddAlertToastMessage("Supplier Transactions section not found in DB");
                return(BadRequest());
            }
            //If section is not our section the canot update disable input controls
            NotUpdatable = WarehouseTransaction.SectionId != section.Id;
            return(Page());
        }
Exemplo n.º 2
0
        public IActionResult Instructor(InstructorViewModel model)
        {
            Validation <InstructorViewModel> instructorViewModel = new Validation <InstructorViewModel>();

            if (ModelState.IsValid)
            {
                if (model != null)
                {
                    instructorViewModel = ınstructorManager.Insert(model);

                    if (instructorViewModel.ErrorList.Count == 0)
                    {
                        _IRedisCacheService.GetAllRemove();
                        toastNotification.AddSuccessToastMessage("Eğitmen Ekleme İşlemi Başarılı");
                        return(RedirectToAction("Instructor"));
                    }
                    else
                    {
                        instructorViewModel.ErrorList.ForEach(x => toastNotification.AddAlertToastMessage(x));
                        return(RedirectToAction("Instructor"));
                    }
                }
                else
                {
                    toastNotification.AddWarningToastMessage("Eğitmen Ekleme İşlemi Sırasında Bir Hata Meydana Geldi!");
                    return(RedirectToAction("Instructor"));
                }
            }
            else
            {
                ModelState.Values.ToList().ForEach(x => x.Errors.ToList().ForEach(y => toastNotification.AddWarningToastMessage(y.ErrorMessage)));
                return(RedirectToAction("Instructor"));
            }
        }
Exemplo n.º 3
0
        public async Task <IActionResult> CriarEndereco(EnderecoViewModel model, UsuarioViewModel usuariomodel)
        {
            var cpf = new CPF(usuariomodel.Cpf);

            cpf.SemFormatacao();

            var usuario = await _userManager.FindByNameAsync(cpf.Codigo);

            if (usuario != null)
            {
                var endereco = new Endereco()
                {
                    ClienteId   = usuario.Id,
                    Cep         = model.Cep,
                    Logradouro  = model.Logradouro,
                    Numero      = model.Numero,
                    Uf          = model.Uf,
                    Bairro      = model.Bairro,
                    Cidade      = model.Cidade,
                    Complemento = model.Complemento
                };

                usuario.Endereco = endereco;
                var result = await _userManager.UpdateAsync(usuario);

                if (!result.Succeeded)
                {
                    _toastNotification.AddAlertToastMessage("Endereço não foi cadastrado!");
                    return(View(model));
                }
            }

            _toastNotification.AddSuccessToastMessage("Endereco Cadastrado!");
            return(RedirectToAction("Index", "Home"));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var transactionToModify = await _context.TransactorTransactions
                                      .Include(t => t.Company)
                                      .Include(t => t.FiscalPeriod)
                                      .Include(t => t.Section)
                                      .Include(t => t.TransTransactorDocSeries)
                                      .Include(t => t.TransTransactorDocType)
                                      .Include(t => t.Transactor).FirstOrDefaultAsync(m => m.Id == id);

            if (transactionToModify == null)
            {
                return(NotFound());
            }

            var section = _context.Sections.SingleOrDefault(s => s.SystemName == _sectionCode);

            if (section is null)
            {
                _toastNotification.AddAlertToastMessage("Supplier Transactions section not found in DB");
                return(BadRequest());
            }
            //If section is not our section the canot update disable input controls
            NotUpdatable = transactionToModify.SectionId != section.Id;

            ItemVm = _mapper.Map <TransactorTransModifyDto>(transactionToModify);
            LoadCombos();
            return(Page());
        }
        public IActionResult Lesson(LessonViewModel modelLesson)
        {
            Validation <LessonViewModel> lessonViewModel = new Validation <LessonViewModel>();

            if (ModelState.IsValid)
            {
                if (modelLesson != null)
                {
                    lessonViewModel = lessonManager.Insert(modelLesson);

                    if (lessonViewModel.ErrorList.Count == 0)
                    {
                        _IRedisCacheService.GetAllRemove();
                        toastNotification.AddSuccessToastMessage("Ders Ekleme İşlemi Başarılı");
                        return(RedirectToAction("Lesson"));
                    }
                    else
                    {
                        lessonViewModel.ErrorList.ForEach(x => toastNotification.AddAlertToastMessage(x));
                        return(RedirectToAction("Lesson"));
                    }
                }
                else
                {
                    toastNotification.AddWarningToastMessage("Ders Ekleme İşlemi Sırasında Bir Hata Meydana Geldi!");
                    return(RedirectToAction("Lesson"));
                }
            }
            else
            {
                ModelState.Values.ToList().ForEach(x => x.Errors.ToList().ForEach(y => toastNotification.AddWarningToastMessage(y.ErrorMessage)));
                return(RedirectToAction("Lesson"));
            }
        }
Exemplo n.º 6
0
        protected void ShowNotification(string message, ToastrSeverity severity)
        {
            switch (severity)
            {
            case ToastrSeverity.Success:
                toastNotification.AddSuccessToastMessage(message);
                break;

            case ToastrSeverity.Info:
                toastNotification.AddInfoToastMessage(message);
                break;

            case ToastrSeverity.Warning:
                toastNotification.AddWarningToastMessage(message);
                break;

            case ToastrSeverity.Error:
                toastNotification.AddErrorToastMessage(message);
                break;

            case ToastrSeverity.Alert:
                toastNotification.AddAlertToastMessage(message);
                break;
            }
        }
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                _toastNotification.AddAlertToastMessage("Please see errors");
                return(Page());
            }

            var materialToAttach = _mapper.Map <WarehouseItem>(WarehouseItemVm);

            _context.Attach(materialToAttach).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();

                _toastNotification.AddSuccessToastMessage("WarehouseItem changes saved");
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MaterialExists(WarehouseItemVm.Id))
                {
                    _toastNotification.AddErrorToastMessage("WarehouseItem was not found");
                    return(NotFound());
                }
                else
                {
                    _toastNotification.AddErrorToastMessage("Concurency error");
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
Exemplo n.º 8
0
        public void ToastNotify(ToastMessageState state, string title, string message, int duration)
        {
            switch (state)
            {
            case ToastMessageState.Success: _toastNotification.AddSuccessToastMessage(message, new ToastrOptions()
                {
                    Title = title, TimeOut = duration
                });
                break;

            case ToastMessageState.Info: _toastNotification.AddInfoToastMessage(message, new ToastrOptions()
                {
                    Title = title, TimeOut = duration
                });
                break;

            case ToastMessageState.Alert: _toastNotification.AddAlertToastMessage(message, new ToastrOptions()
                {
                    Title = title, TimeOut = duration
                });
                break;

            case ToastMessageState.Warning: _toastNotification.AddWarningToastMessage(message, new ToastrOptions()
                {
                    Title = title, TimeOut = duration
                });
                break;

            case ToastMessageState.Error: _toastNotification.AddErrorToastMessage(message, new ToastrOptions()
                {
                    Title = title, TimeOut = duration
                });
                break;
            }
        }
Exemplo n.º 9
0
        public async Task <IActionResult> LogIn(WebApp.Identity.Models.LoginModel model)
        {
            if (string.IsNullOrWhiteSpace(model?.Email) || string.IsNullOrWhiteSpace(model?.Password))
            {
                _toastNotification.AddAlertToastMessage("Para autenticar, informe o seu e-mail e a sua senha");
                return(View());
            }
            else
            {
                var user = await _userManager.FindByEmailAsync(model.Email);

                if (user == null)
                {
                    ModelState.AddModelError("", "Usuário não encontrado");
                    return(View());
                }
                else
                {
                    if (await _userManager.CheckPasswordAsync(user, model.Password))
                    {
                        var principal = await _userClaimsPrincipalFactory.CreateAsync(user);

                        await HttpContext.SignInAsync(IdentityConstants.ApplicationScheme, principal);

                        _toastNotification.AddSuccessToastMessage($"Seja bem-vindo, {user.UserName}");
                        return(RedirectToAction("Index", "Home"));
                    }
                    else
                    {
                        _toastNotification.AddAlertToastMessage("Usuário ou senha inválido");
                    }
                }
            }

            return(View());
        }
Exemplo n.º 10
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var transToEdit = await _context.WarehouseTransactions
                              .Include(w => w.Company)
                              .Include(w => w.FiscalPeriod)
                              .Include(w => w.WarehouseItem)
                              .Include(w => w.Section)
                              .Include(w => w.TransWarehouseDocSeries)
                              .Include(w => w.TransWarehouseDocType).FirstOrDefaultAsync(m => m.Id == id);

            if (transToEdit == null)
            {
                return(NotFound());
            }
            var section = _context.Sections.SingleOrDefault(s => s.SystemName == SectionSystemCode);

            if (section is null)
            {
                _toastNotification.AddAlertToastMessage("Warehouse Transactions section not found in DB");
                return(BadRequest());
            }
            //If section is not our section the cannot update disable input controls
            NotUpdatable = transToEdit.SectionId != section.Id;

            ItemVm = _mapper.Map <WarehouseTransModifyDto>(transToEdit);
            var mainUnit = await _context.MeasureUnits.SingleOrDefaultAsync(p => p.Id == transToEdit.PrimaryUnitId);

            var secUnit = await _context.MeasureUnits.SingleOrDefaultAsync(p => p.Id == transToEdit.SecondaryUnitId);

            ItemVm.PrimaryUnitCode   = mainUnit == null ? "UNK" : mainUnit.Code;
            ItemVm.SecondaryUnitCode = secUnit == null ? "UNK" : secUnit.Code;

            LoadCombos();
            return(Page());
        }
Exemplo n.º 11
0
 public IActionResult About()
 {
     ViewData["Message"] = "Your application description page.";
     _toastNotification.AddAlertToastMessage("My About Warning Message");
     return(View());
 }
Exemplo n.º 12
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                _toastNotification.AddAlertToastMessage("Please see errors");
                return(Page());
            }
            await using var transaction = await _context.Database.BeginTransactionAsync();

            try
            {
                var materialToAttach = _mapper.Map <WarehouseItem>(ItemVm);
                materialToAttach.DateLastModified       = DateTime.Today;
                _context.Attach(materialToAttach).State = EntityState.Modified;
                _context.CompanyWarehouseItemMappings.RemoveRange(_context.CompanyWarehouseItemMappings.Where(p => p.WarehouseItemId == materialToAttach.Id));

                int[] companiesSelected = JsonSerializer.Deserialize <int[]>(ItemVm.SelectedCompanies);
                foreach (var i in companiesSelected)
                {
                    materialToAttach.CompanyMappings.Add(new CompanyWarehouseItemMapping
                    {
                        CompanyId       = i,
                        WarehouseItemId = materialToAttach.Id
                    });
                }

                await _context.SaveChangesAsync();

                await transaction.CommitAsync();

                _toastNotification.AddSuccessToastMessage("WarehouseItem changes saved");
            }
            catch (DbUpdateConcurrencyException)
            {
                await transaction.RollbackAsync();

                ModelState.AddModelError("", "Concurency error");
                if (!MaterialExists(ItemVm.Id))
                {
                    _toastNotification.AddErrorToastMessage("WarehouseItem was not found");
                    return(NotFound());
                }
                else
                {
                    _toastNotification.AddErrorToastMessage("Concurency error");
                    LoadCombos();
                    return(Page());
                }
            }
            catch (Exception e)
            {
                await transaction.RollbackAsync();

                ModelState.AddModelError("", e.Message);
                _toastNotification.AddErrorToastMessage(e.Message);
                LoadCombos();
                return(Page());
            }

            return(RedirectToPage("./Index"));
        }
Exemplo n.º 13
0
 public IActionResult Contact()
 {
     _toastNotification.AddAlertToastMessage("You will be redirected to about page");
     return(RedirectToAction("About"));
 }