Пример #1
0
        public async Task <IActionResult> DetailsAsync(int id)
        {
            ClientFormViewModel viewModel = new ClientFormViewModel();
            Client client = await _clientRepository.FindByIdAsync(id, _employeeLogin.GetEmployee().BusinessId);

            if (client is ClientJuridical)
            {
                viewModel.ClientJuridical = (ClientJuridical)client;
            }
            else
            {
                viewModel.ClientPhysical = (ClientPhysical)client;
            }
            foreach (var item in client.Contacts)
            {
                if (item.TypeNumber == Models.Enums.TypeNumber.Celular)
                {
                    viewModel.Celular = item;
                }
                if (item.TypeNumber == Models.Enums.TypeNumber.Residencial)
                {
                    viewModel.Comercial = item;
                }
            }
            viewModel.Address = client.Address;
            return(View(viewModel));
        }
Пример #2
0
 public IActionResult Insert(ClientFormViewModel client)
 {
     if (ModelState.IsValid)
     {
         if (client.ClientJuridical != null)
         {
             client.ClientJuridical.InsertDate         = DateTime.Now;
             client.ClientJuridical.Address.InsertDate = DateTime.Now;
             foreach (var item in client.ClientJuridical.Contacts)
             {
                 item.InsertDate = DateTime.Now;
             }
             client.ClientJuridical.RegisterEmployeeId = _employeeLogin.GetEmployee().Id;
             _clientRepository.Insert(client.ClientJuridical);
         }
         else
         {
             client.ClientPhysical.InsertDate         = DateTime.Now;
             client.ClientPhysical.Address.InsertDate = DateTime.Now;
             foreach (var item in client.ClientPhysical.Contacts)
             {
                 item.InsertDate = DateTime.Now;
             }
             client.ClientPhysical.RegisterEmployeeId = _employeeLogin.GetEmployee().Id;
             _clientRepository.Insert(client.ClientPhysical);
         }
         TempData["MSG_S"] = Message.MSG_S_002;
         return(Json("Ok"));
     }
     return(Json("Error"));
 }
Пример #3
0
        public IActionResult Credits(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var cliente = _clientService.FindById(id);

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

            if (cliente.UserId != userId)
            {
                return(NotFound());
            }

            List <Credit>       credits      = _creditService.FindValidCreditsByClient(id);
            int                 totalBalance = _creditService.GetTotalBalance(id);
            ClientFormViewModel viewModel    = new ClientFormViewModel {
                Client = cliente, Credits = credits, TotalBalance = totalBalance
            };

            return(View(viewModel));
        }
        public ActionResult Make(int id)
        {
            try
            {
                var contactModel = contactRepository.Find(id);

                var clientModel = new ClientFormViewModel()
                {
                    FirstName    = contactModel.FirstName,
                    LastName     = contactModel.LastName,
                    EmailAddress = contactModel.EmailAddress,
                    Address      = contactModel.Address,
                    City         = contactModel.City,
                    State        = contactModel.State,
                    ZipCode      = contactModel.ZipCode,
                    Phone        = contactModel.Phone,
                    Notes        = contactModel.Comments
                };

                return(View("Create", clientModel));
            }
            catch (Exception ex)
            {
                base.ViewData["Exception"] = "Exception: " + ex.InnerException.ToString();
                throw;
            }
        }
Пример #5
0
        public void ClientValidate_PAZipCodeIs1106ButNoPALocality()
        {
            ClientFormViewModel vm = new ClientFormViewModel(new Client(
                                                                 )
            {
                FirstName        = "István",
                LastName         = "Kiss",
                BirthName        = "Kiss István",
                BirthPlace       = "Budapest",
                BirthDate        = DateTime.Parse("1960/01/01"),
                MothersLastName  = "Ágnes",
                MothersFirstName = "Szabó",
                SSN        = 111222333,
                HAZIPCode  = 1106,
                HALocality = "Budapest",
                HAStreet   = "Jászberényi út",
                HANumber   = "47/E",
                PAZIPCode  = 1106,
                PAStreet   = "Jászberényi út",
                PANumber   = "47/E"
            }
                                                             );
            bool test = vm.ClientValidate();

            Assert.IsFalse(test);
        }
Пример #6
0
        public ActionResult AddClientForm(ClientFormViewModel client)
        {
            if (ModelState.IsValid)
            {
                Client dbClient = client;
                clientService.CreateClient(dbClient);
                try
                {
                    clientService.SaveClient();
                    ViewBag.MainMessage = "New client added successfully.";
                    ViewBag.MessageType = "success";
                }
                catch (Exception e) {
                    //Pozeljno je dodatno implementirati bolji exception handling
                    //koji bi uključivao i logovanje izuzetaka
                    ViewBag.MainMessage = "Error, new client was not added.";
                    ViewBag.MessageType = "danger";
                }

                return(View());
            }
            else
            {
                return(View(client));
            }
        }
Пример #7
0
        public ClientFormPage(Client client) : this()
        {
            ClientFormViewModel vm = (ClientFormViewModel)BindingContext;

            vm.Client = client;
            vm.Title  = "Modifier";
        }
Пример #8
0
        public ActionResult Update(ClientFormViewModel client)
        {
            var dbClient = client;

            if (ModelState.IsValid)
            {
                try
                {
                    clientService.UpdateClient(dbClient);
                    clientService.SaveClient();
                    //Poruke bi trebale biti izdvojene u zaseban file zbog mogucnosti lokalizacije u buducnosti
                    TempData["MainMessage"] = "Client was updated successfully.";
                    TempData["MessageType"] = "success";
                }
                catch (Exception e)
                {
                    TempData["MainMessage"] = "Error, client was not updated.";
                    TempData["MessageType"] = "danger";
                }
            }
            else
            {
                var clients = clientService.GetClients();
                ViewBag.Clients = clients;
                return(View("UpDelClientForm", client));
            }

            return(RedirectToAction("UpDelClientForm"));
        }
Пример #9
0
        public ActionResult Save(Client client)
        {
            if (!ModelState.IsValid)
            {
                var viewModel = new ClientFormViewModel()
                {
                    Client  = client,
                    Manager = _context.Managers.ToList()
                };

                return(View("ClientForm", viewModel));
            }

            if (client.Id == 0)
            {
                _context.Clients.Add(client);
            }
            else
            {
                var clietnInDb = _context.Clients.Single(c => c.Id == client.Id);

                clietnInDb.FirstName = client.FirstName;
                clietnInDb.LastName  = client.LastName;
                clietnInDb.ManagerId = client.ManagerId;
            }

            _context.SaveChanges();

            return(RedirectToAction("Index", "Clients"));
        }
Пример #10
0
 public IActionResult Edit(Client client)
 {
     TempData.Keep();
     if (!_clientsRepo.VerifyTributaryId(client.TributaryId) && !_clientsRepo.VerifyTributaryIdOwnership(client.Id, client.TributaryId))
     {
         ModelState.AddModelError("uqTributaryId", "La identificación tributaria especificada ya está asociada a otro cliente registrado");
     }
     if (!ModelState.IsValid)
     {
         ClientFormViewModel viewModel = new ClientFormViewModel
         {
             BillingModes            = _billingModesRepo.BillingModes.ToList(),
             ClientTypes             = _clientTypesRepo.ClientTypes.ToList(),
             DocumentDeliveryMethods = _documentDeliveryMethodsRepo.DocumentDeliveryMethods.ToList()
         };
         viewModel.Client = client;
         return(View(viewModel));
     }
     else
     {
         _clientsRepo.Save(client);
         TempData["updated"] = true;
         return(RedirectToAction("Admin", new { filter = TempData["filter"] }));
     }
 }
Пример #11
0
        public IActionResult Extracts(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var cliente = _clientService.FindById(id);

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

            if (cliente.UserId != userId)
            {
                return(NotFound());
            }

            List <Extract>      extracts  = _extractService.FindExtractsByClient(id);
            ClientFormViewModel viewModel = new ClientFormViewModel {
                Client = cliente, Extracts = extracts
            };

            CultureInfo daDK = CultureInfo.CreateSpecificCulture("da-DK");

            ViewData["TotalBalance"] = _creditService.GetTotalBalance(id).ToString("00.00", daDK);

            return(View(viewModel));
        }
        public ActionResult Details(int id)
        {
            Client clientInDb = _context.Clients.Where(x => x.client_id == id).FirstOrDefault();

            if (clientInDb == null)
            {
                ModelState.AddModelError("", "Not found.");
                return(View("ClientForm", clientInDb));
            }

            ClientFormViewModel viewModel = new ClientFormViewModel
            {
                client_id                = clientInDb.client_id,
                client_name              = clientInDb.client_name,
                Regions                  = ManageDependancyData.GetRegions(),
                Industries               = ManageDependancyData.GetIndustryTypes(),
                branch                   = clientInDb.branch,
                region_id                = clientInDb.region_id,
                industry_id              = clientInDb.region_id,
                site_address             = clientInDb.site_address,
                remarks                  = clientInDb.remarks,
                corporate_office_address = clientInDb.corporate_office_address,
                Title = "Client Details"
            };

            return(View("ClientForm", viewModel));
        }
        // HTTP GET: /Client/Edit/1
        public ActionResult Edit(int id)
        {
            Client client = clientRepository.Find(id);

            if (client == null)
            {
                ViewBag.RecordType = "Client";
                return(View("NotFound"));
            }

            ViewData["Edit"] = client.FirstName + " " + client.LastName;

            var viewModel = new ClientFormViewModel(client.SourceID)
            {
                FirstName     = client.FirstName,
                LastName      = client.LastName,
                EmailAddress  = client.EmailAddress,
                Address       = client.Address,
                City          = client.City,
                State         = client.State,
                ZipCode       = client.ZipCode,
                Phone         = client.Phone,
                DOB           = client.DOB,
                Height        = client.Height,
                StartWeight   = client.StartWeight,
                Doctor        = client.Doctor,
                MaritalStatus = client.MaritalStatus,
                Occupation    = client.Occupation,
                SourceID      = client.SourceID,
                Notes         = client.Notes
            };

            return(View("EditClient", viewModel));
        }
Пример #14
0
        public ActionResult Save(Client client)
        {
            if (!ModelState.IsValid)
            {
                var status    = _context.Status.ToList();
                var viewModel = new ClientFormViewModel
                {
                    Client = client,
                    Status = status
                };

                return(View("StaffForm", viewModel));
            }
            if (client.Id == 0)
            {
                _context.Clients.Add(client);
            }
            else
            {
                var clientInDb = _context.Clients.Single(c => c.Id == client.Id);

                clientInDb.Address     = client.Address;
                clientInDb.Name        = client.Name;
                clientInDb.StatusId    = client.StatusId;
                clientInDb.PhoneNumber = client.PhoneNumber;
                clientInDb.Contact     = client.Contact;
            }
            _context.SaveChanges();

            return(RedirectToAction("Index", "Client"));
        }
        public ActionResult Save(Client client)
        {
            if (!ModelState.IsValid)
            {
                var viewModel = new ClientFormViewModel
                {
                    Client       = client,
                    ConsoleTypes = _context.ConsoleTypes.ToList()
                };


                return(View("ClientForm", viewModel));
            }


            if (client.ClientID == 0)
            {
                _context.Clients.Add(client);
            }
            else
            {
                var clientInDb = _context.Clients.Single(c => c.ClientID == client.ClientID);

                clientInDb.Name = client.Name;
                clientInDb.IsSubscribedOnSteam = client.IsSubscribedOnSteam;
                clientInDb.ConsoleTypeID       = client.ConsoleTypeID;
            }

            _context.SaveChanges();
            return(RedirectToAction("Index", "Clients"));
        }
Пример #16
0
        public ActionResult Save(Client client) // recebemos um cliente
        {
            if (!ModelState.IsValid)
            {
                var viewModel = new ClientFormViewModel
                {
                    Client = client
                };

                return(View("ClientForm", viewModel));
            }

            if (client.Id == 0)
            {
                // armazena o cliente em memória
                _context.Clients.Add(client);
            }
            else
            {
                var clientInDb = _context.Clients.Single(c => c.Id == client.Id);

                clientInDb.Name       = client.Name;
                clientInDb.Document   = client.Document;
                clientInDb.BirthDate  = client.BirthDate;
                clientInDb.CivilState = client.CivilState;
                clientInDb.Sex        = client.Sex;
            }

            // faz a persistência
            _context.SaveChanges();
            // Voltamos para a lista de clientes
            return(RedirectToAction("Index"));
        }
Пример #17
0
        public ActionResult New()
        {
            var clientmodel = new ClientFormViewModel
            {
                Client = new Client()
            };

            return(View("ClientForm", clientmodel));
        }
        public ActionResult Insert()
        {
            var cities    = cityRepository.GetAll().OrderBy(c => c.Name);
            var viewModel = new ClientFormViewModel
            {
                Cities = cities
            };

            return(View(viewModel));
        }
Пример #19
0
        public ActionResult New()
        {
            var status    = _context.Status.ToList();
            var viewModel = new ClientFormViewModel
            {
                Status = status
            };

            return(View("ClientForm", viewModel));
        }
Пример #20
0
        public ActionResult New()
        {
            var manager   = _context.Managers.ToList();
            var viewModel = new ClientFormViewModel
            {
                Client  = new Client(),
                Manager = manager
            };

            return(View("ClientForm", viewModel));
        }
Пример #21
0
        public ActionResult New()
        {
            var viewModel = new ClientFormViewModel
            {
                Client       = new Client(),
                ClientStatus = dbContext.ClientStatuses.ToList(),
                ClientType   = dbContext.ClientTypes.ToList()
            };

            return(View("ClientForm", viewModel));
        }
        public ViewResult New()
        {
            var consoleTypes = _context.ConsoleTypes.ToList();

            var viewModel = new ClientFormViewModel
            {
                Client       = new Client(),
                ConsoleTypes = consoleTypes
            };

            return(View("ClientForm", viewModel));
        }
        public ActionResult Details(int id)
        {
            var client    = clientRepository.Get(id);
            var userLogin = userLoginRepository.Get(id);
            var viewModel = new ClientFormViewModel
            {
                Client    = client,
                UserLogin = userLogin
            };

            return(View(viewModel));
        }
        public ActionResult New()
        {
            ClientFormViewModel viewModel = new ClientFormViewModel
            {
                client_id  = 0,
                Regions    = ManageDependancyData.GetRegions(),
                Industries = ManageDependancyData.GetIndustryTypes(),
                Title      = "New Client"
            };

            return(View("ClientForm", viewModel));
        }
Пример #25
0
        public void ClientValidate_WithoutName()
        {
            ClientFormViewModel vm = new ClientFormViewModel(new Client(
                                                                 )
            {
                FirstName = null
            }
                                                             );
            bool test = vm.ClientValidate();

            Assert.IsFalse(test);
        }
Пример #26
0
        public void ClientValidate_SSNIs1Million()
        {
            ClientFormViewModel vm = new ClientFormViewModel(new Client(
                                                                 )
            {
                SSN = 1000000000
            }
                                                             );
            bool test = vm.ClientValidate();

            Assert.IsFalse(test);
        }
Пример #27
0
        public void ClientValidate_ZipCodeIs10000()
        {
            ClientFormViewModel vm = new ClientFormViewModel(new Client(
                                                                 )
            {
                HAZIPCode = 10000
            }
                                                             );
            bool test = vm.ClientValidate();

            Assert.IsFalse(test);
        }
Пример #28
0
        public void ClientValidate_PAZipCodeIs999()
        {
            ClientFormViewModel vm = new ClientFormViewModel(new Client(
                                                                 )
            {
                PAZIPCode = 999
            }
                                                             );
            bool test = vm.ClientValidate();

            Assert.IsFalse(test);
        }
Пример #29
0
        public ActionResult New()
        {
            var provinces = _context.Provinces.ToList();
            var companies = _context.Companies.ToList();
            var viewModel = new ClientFormViewModel
            {
                Provinces = provinces,
                Companies = companies
            };

            return(View(viewModel));
        }
Пример #30
0
        public ViewResult New()
        {
            ClientFormViewModel viewModel = new ClientFormViewModel
            {
                BillingModes            = _billingModesRepo.BillingModes.ToList(),
                ClientTypes             = _clientTypesRepo.ClientTypes.ToList(),
                DocumentDeliveryMethods = _documentDeliveryMethodsRepo.DocumentDeliveryMethods.ToList(),
                Client = new Client()
            };

            ViewBag.AddedClient = TempData["added"];
            return(View(viewModel));
        }