コード例 #1
0
 private void GetLocationSelectTagHelper(BranchRegisterViewModel model)
 {
     ViewBag.Countries =
         _countryBusiness.GetCountries()
         .Select(c => new SelectListItem {
         Text = c.Name, Value = c.Id.ToString()
     })
         .ToList();
     ViewBag.Provinces = _provinceBusiness.GetProvincesByCountry(Guid.Parse(model.IdCountry))
                         .Select(c => new SelectListItem {
         Text = c.Name, Value = c.Id.ToString()
     })
                         .ToList();
     ViewBag.Districts = _districtBusiness.GetDistrictByProvince(Guid.Parse(model.IdProvince))
                         .Select(c => new SelectListItem {
         Text = c.Name, Value = c.Id.ToString()
     })
                         .ToList();
     ViewBag.Parishes = _parishBusiness.GetParishByDistrict(Guid.Parse(model.IdDistrict))
                        .Select(c => new SelectListItem {
         Text = c.Name, Value = c.Id.ToString()
     })
                        .ToList();
     ViewBag.Sectors = _sectorBusiness.GetSectorByDistrict(Guid.Parse(model.IdDistrict))
                       .Select(c => new SelectListItem {
         Text = c.Name, Value = c.Id.ToString()
     })
                       .ToList();
 }
コード例 #2
0
        public void AddAccount(BranchRegisterViewModel model, Guid idAccount)
        {
            var branchCustomer = new BranchCustomer()
            {
                IdBranch       = model.Id,
                IdChannel      = model.IdChannel,
                IdCustomer     = model.IdCustomer,
                IdTypeBusiness = model.IdTypeBusiness
            };

            _branchCustomerDao.InsertOrUpdate(branchCustomer);
        }
コード例 #3
0
        public bool Save(BranchRegisterViewModel model, Guid idAccount)
        {
            var branch = ConvertBranch.FromBranchRegisterViewModel(model);
            //Recupero personas por Documento
            var person = _personDao.GetPersonByDocument(branch.PersonOwner.Document);

            branch.IdPersonOwner = person?.Id ?? Guid.Empty;

            person = _personDao.GetPersonByDocument(branch.PersonAdministration.Document);
            branch.IdPersonAdministrator = person?.Id ?? Guid.Empty;

            SaveBranch(branch, idAccount);
            return(true);
        }
コード例 #4
0
        public IActionResult Register(Guid idBranch, string returnUrl = null)
        {
            ViewData["ReturnUrl"] = returnUrl;
            var modelView = new BranchRegisterViewModel();

            if (idBranch != Guid.Empty)
            {
                modelView = _branchBusiness.GetBranchForRegister(idBranch, ApplicationUserCurrent.AccountId);
                GetLocationSelectTagHelper(modelView);
            }

            ViewData[CBranch.IdRegister] = idBranch;

            return(View());
        }
コード例 #5
0
        public static Branch FromBranchRegisterViewModel(BranchRegisterViewModel viewModel)
        {
            Mapper.Initialize(cfg =>
            {
                cfg.CreateMap <BranchRegisterViewModel, Branch>()
                .ForMember(dest => dest.IdParish, opt => opt.MapFrom(src => Guid.Parse(src.IdParish)))
                .ForMember(dest => dest.IdCountry, opt => opt.MapFrom(src => Guid.Parse(src.IdCountry)))
                .ForMember(dest => dest.IdDistrict, opt => opt.MapFrom(src => Guid.Parse(src.IdDistrict)))
                .ForMember(dest => dest.IdProvince, opt => opt.MapFrom(src => Guid.Parse(src.IdProvince)))
                .ForMember(dest => dest.IdSector, opt => opt.MapFrom(src => Guid.Parse(src.IdSector)))
                .ForMember(dest => dest.IsAdministratorOwner, opt => opt.MapFrom(src => src.IsAdministratorOwner ? "SI" : "NO"))
                .ForMember(dest => dest.CreationDate, opt => opt.MapFrom(src => src.CreationDate))
                .ForMember(dest => dest.LatitudeBranch, opt => opt.MapFrom(src => src.Latitude.ToString(CultureInfo.InvariantCulture)))
                .ForMember(dest => dest.LenghtBranch, opt => opt.MapFrom(src => src.Longitude.ToString(CultureInfo.InvariantCulture)))
                .ForMember(dest => dest.StatusRegister, opt => opt.MapFrom(src => src.StatusRegister ?? CStatusRegister.Active));
                cfg.CreateMap <BranchRegisterViewModel, Person>()
                .ForMember(dest => dest.Document, opt => opt.MapFrom(src => src.AdministratorDocument))
                .ForMember(dest => dest.Name, opt => opt.MapFrom(src => src.AdministratorName))
                .ForMember(dest => dest.SurName, opt => opt.MapFrom(src => src.AdministratorSurname))
                .ForMember(dest => dest.Phone, opt => opt.MapFrom(src => src.AdministratorPhone))
                .ForMember(dest => dest.Mobile, opt => opt.MapFrom(src => src.AdministratorCellPhone))
                .ForMember(dest => dest.TypeDocument, opt => opt.MapFrom(src => "CI"));
                cfg.CreateMap <BranchRegisterViewModel, Person>()
                .ForMember(dest => dest.Document, opt => opt.MapFrom(src => src.OwnerDocument))
                .ForMember(dest => dest.Name, opt => opt.MapFrom(src => src.OwnerName))
                .ForMember(dest => dest.SurName, opt => opt.MapFrom(src => src.OwnerSurname))
                .ForMember(dest => dest.Phone, opt => opt.MapFrom(src => src.OwnerPhone))
                .ForMember(dest => dest.Mobile, opt => opt.MapFrom(src => src.OwnerCellPhone))
                .ForMember(dest => dest.TypeDocument, opt => opt.MapFrom(src => src.OwnerTypeDocument ?? "CI"));
                cfg.CreateMap <BranchCustomersViewModel, BranchCustomer>();
            }
                              );

            var branch = Mapper.Map <BranchRegisterViewModel, Branch>(viewModel);

            branch.PersonAdministration = Mapper.Map <BranchRegisterViewModel, Person>(viewModel);
            branch.PersonOwner          = Mapper.Map <BranchRegisterViewModel, Person>(viewModel);

            branch.CreationDate = branch.CreationDate.Year < 2010 ? DateTime.Now : branch.CreationDate;

            return(branch);
        }
コード例 #6
0
        public IActionResult AddAccount(BranchRegisterViewModel model)
        {
            try
            {
                if (model.Id == Guid.Empty)
                {
                    ModelState.AddModelError("Unsaved", "Para Agregar Cuentas debe primero guardar el Local");
                }

                if (!ModelState.IsValid)
                {
                    return(RedirectToAction("Register", new { idBranch = model.Id }));
                }

                _branchBusiness.AddAccount(model, ApplicationUserCurrent.AccountId);

                return(RedirectToAction("Register", new { idBranch = model.Id }));
            }
            catch (Exception e)
            {
                _logger.LogError(new EventId(0, "Error Index"), e.Message);
                return(RedirectToAction("Index", "StatusCode", new { statusCode = 1 }));
            }
        }