Exemple #1
0
        public async Task <IActionResult> ReturnInfoAnaf(CustomerViewModel model)
        {
            model.data = DateTime.Today.ToString("yyyy-MM-dd");
            GetInfoAnafViewModel info = new GetInfoAnafViewModel
            {
                cui  = model.cui,
                data = model.data
            };
            HttpResponseMessage result = await client.PostAsJsonAsync("https://webservicesp.anaf.ro/PlatitorTvaRest/api/v3/ws/tva",
                                                                      new List <GetInfoAnafViewModel>() { info });

            HttpContent content       = result.Content;
            string      resultContent = await content.ReadAsStringAsync();

            InfoAnafModel modelInfoAnaf = new InfoAnafModel();

            if (resultContent != null)
            {
                dynamic json          = JValue.Parse(resultContent);
                dynamic requestedFirm = json.found[0];
                modelInfoAnaf = new InfoAnafModel
                {
                    cui      = requestedFirm.cui,
                    Address  = requestedFirm.adresa,
                    FirmName = requestedFirm.denumire
                };
            }
            else
            {
                return(RedirectToAction("ErrorRegister"));
            }

            return(View(modelInfoAnaf));
        }
Exemple #2
0
        public async Task <IActionResult> CreateCustomerAnaf(InfoAnafModel model)
        {
            var      IdPartner = _userManager.GetUserId(User);
            Customer customer  = new Customer()
            {
                FirmName  = model.FirmName,
                Address   = model.Address,
                Email     = model.Email,
                IdPartner = IdPartner
            };

            _context.Customers.Add(customer);
            await _context.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Exemple #3
0
        public async Task <IActionResult> Register(InfoAnafModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View("Error"));
            }

            var user = new Partner()
            {
                UserName = model.Email,
                Email    = model.Email,
                Address  = model.Address,
                cui      = model.cui,
                FirmName = model.FirmName
            };
            var result = await userManager.CreateAsync(
                user, model.Password);

            if (!await roleManager.RoleExistsAsync("Partner"))
            {
                await roleManager.CreateAsync(new IdentityRole { Name = "Partner" });
            }


            await userManager.AddToRoleAsync(user, "Partner");

            if (result.Succeeded)
            {
                return(View("RegistrationConfirmation"));
            }

            foreach (var error in result.Errors)
            {
                ModelState.AddModelError("error", error.Description);
            }
            return(View(model));
        }