Esempio n. 1
0
        public IActionResult OnPost()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }
            _service.CreateAndSave(Data);
            if (_service.IsValid)
            {
                return(RedirectToPage("Index", new { message = _service.Message }));
            }

            //Error state
            _service.CopyErrorsToModelState(ModelState, Data, nameof(Data));
            return(Page());
        }
Esempio n. 2
0
        public ActionResult Create(PessoaDto pessoa)
        {
            if (!ModelState.IsValid)
            {
                return(View(pessoa));
            }

            _service.CreateAndSave(pessoa);
            if (_service.IsValid)
            {
                return(RedirectToAction("Index", new { message = /* _service.Message */ "Criado com sucesso" }));
            }

            //Error state
            _service.CopyErrorsToModelState(ModelState, pessoa, nameof(pessoa));
            return(View(pessoa));
        }
Esempio n. 3
0
        public ActionResult <WebApiMessageAndResult <User> > Create()
        {
            var user = new User
            {
                Id   = Guid.NewGuid(),
                Name = "abc"
            };

            _services.CreateAndSave(user);

            Console.WriteLine("--- create ---");
            Console.WriteLine($"isvalid - {_services.IsValid}");
            Console.WriteLine($"message - {_services.Message}");
            Console.WriteLine($"errors - {JsonSerializer.Serialize(_services.Errors)}");

            return(_services.Response(user));
        }
        public IActionResult Till([FromServices] ICrudServices <CompanyDbContext> service, SellItemDto dto)
        {
            if (!ModelState.IsValid)
            {
                dto.SetResetDto(service.ReadManyNoTracked <StockSelectDto>().ToList());
                return(View(dto));
            }

            var result = service.CreateAndSave(dto);

            if (service.IsValid)
            {
                return(RedirectToAction("BuySuccess", new { message = service.Message, result.ShopSaleId }));
            }

            //Error state
            service.CopyErrorsToModelState(ModelState, dto);
            dto.SetResetDto(service.ReadManyNoTracked <StockSelectDto>().ToList());
            return(View(dto));
        }
        public IActionResult OnPost()
        {
            if (!ModelState.IsValid)
            {
                Data.BeforeDisplay(_service.Context);
                return(Page());
            }
            //Now I need to set up the Authors collection before calling create
            Data.BeforeSave(_service.Context);
            _service.CreateAndSave(Data);
            if (_service.IsValid)
            {
                return(RedirectToPage("BookUpdated", new { message = _service.Message }));
            }

            //Error state
            _service.CopyErrorsToModelState(ModelState, Data, nameof(Data));
            Data.BeforeDisplay(_service.Context);
            return(Page());
        }
Esempio n. 6
0
 public void Add(MemberResourceForSave member)
 {
     service.CreateAndSave(member);
 }