Ejemplo n.º 1
0
        public ActionResult ClientesEdit(int?ClientID)
        {
            ClienteViewModel model = new ClienteViewModel();

            context = new DALContext();

            if (ClientID > 0)
            {
                model.Customer          = context.Customers.Find(p => p.Id == ClientID);
                model.Customer.Document = model.Customer.Document.Replace(".", "").Replace("-", "").Replace("/", "");
                model.Customer.ZipCode  = model.Customer.ZipCode.Replace("-", "");
                model.Cities            = context.Cities.Filter(p => p.StateId == model.Customer.AddressStateId).OrderBy(p => p.Name).ToList();
                model.Cities.Insert(0, new City()
                {
                    Id = 0, Name = "SELECIONE..."
                });

                model.Vendedores = context.VendorsCustomer.Filter(p => p.CustomerID == ClientID).Select(p => p.Vendor).ToList();
                model.Vendedores.Insert(0, new Vendor()
                {
                    Id = 0, Name = "SELECIONE..."
                });
            }

            return(View(model));
        }
Ejemplo n.º 2
0
        public ActionResult ContatoSave(Contact model)
        {
            context = new DALContext();

            try
            {
                model.RegisterDate = DateTime.Now;
                model.LastUpdate   = DateTime.Now;

                if (ModelState.IsValid)
                {
                    if (model.VendorID == null)
                    {
                        model.VendorID = 1;
                    }

                    if (model.Id > 0)
                    {
                        context.Contacts.Update(model);
                    }
                    else
                    {
                        context.Contacts.Create(model);
                    }
                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            ViewBag.Message = "Contato cadastrado com sucesso.";

            return(RedirectToAction("Contatos"));
        }
Ejemplo n.º 3
0
        public ActionResult VendedorSave(Vendor model)
        {
            context = new DALContext();

            try
            {
                if (model.PercentCommission <= 0)
                {
                    model.PercentCommission = 5;
                }

                if (model.Id > 0)
                {
                    context.Vendors.Update(model);
                }
                else
                {
                    context.Vendors.Create(model);
                }
                context.SaveChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            ViewBag.Message = "Vendedor cadastrado com sucesso.";

            return(RedirectToAction("Vendedores"));
        }
Ejemplo n.º 4
0
        public ActionResult ClientesSave(Customer model)
        {
            context = new DALContext();

            try
            {
                model.RegisterDate = DateTime.Now;
                model.LastUpdate   = DateTime.Now;

                if (model.Id > 0)
                {
                    context.Customers.Update(model);
                }
                else
                {
                    context.Customers.Create(model);
                }
                context.SaveChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            ViewBag.Message = "Cliente cadastrado com sucesso.";

            return(RedirectToAction("Clientes"));
        }
Ejemplo n.º 5
0
        public ActionResult Recebimento()
        {
            context = new DALContext();
            var Orders = context.PurchaseOrders.Filter(p => p.Status == "PEDIDO_PENDENTE").ToList();

            return(View(Orders));
        }
Ejemplo n.º 6
0
        public ActionResult CondicaoPagamentoSave(PaymentTerm PaymentTerm)
        {
            context = new DALContext();

            try
            {
                //prod.AliqICMS = 3;
                //prod.CombinedProduct = false;
                //prod.MinimumStockAlert = 50;
                if (PaymentTerm.Id > 0)
                {
                    context.PaymentTerms.Update(PaymentTerm);
                }
                else
                {
                    context.PaymentTerms.Create(PaymentTerm);
                }
                context.SaveChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            ViewBag.Message = "Condição de Pagamento cadastrada com sucesso.";

            return(RedirectToAction("CondicaoPagamento"));
        }
Ejemplo n.º 7
0
        //public ActionResult ProdutosPendentes()
        //{
        //    try
        //    {
        //        context = new DALContext();

        //        var ListaProdutosPendentes = context.Products.Filter(p => p.QuantityCurrentStock < 0).ToList();
        //        return View(ListaProdutosPendentes);
        //    }
        //    catch (Exception ex)
        //    {
        //        return Content(ex.Message);
        //    }
        //}

        public ActionResult ProdutosPendentes()
        {
            try
            {
                context = new DALContext();

                var ListaProdutosPendenteCompra = context.Products.Filter(p => p.QuantityCurrentStock < 0).ToList();

                int[] idProduto = ListaProdutosPendenteCompra.Select(p => p.Id).Distinct().ToArray();

                var ListaProdutosPendentes = context.ProductProviders.Filter(p => idProduto.Contains(p.ProductID)).ToList();

                var ListaProdutosCarteiraEstoque = ListaProdutosPendentes.Select(p => new ProdutoCarteiraEstoqueViewModel()
                {
                    Product         = context.Products.Find(q => q.Id == p.ProductID),
                    ProductProvider = p
                }).ToList();

                return(View("ProdutosCarteiraEstoque", ListaProdutosCarteiraEstoque));
            }
            catch (Exception ex)
            {
                return(Content(ex.Message));
            }
        }
Ejemplo n.º 8
0
        public TestBussiness()
        {
            user = new User
            {
                UserName = "******",
                Role     = "Tester",
                Enabled  = true
            };

            var users = new List <User>
            {
                new User {
                    UserId = 1, UserName = "******", Role = "Description", Enabled = true
                },
                new User {
                    UserId = 2, UserName = "******", Role = "PM", Enabled = true
                },
                new User {
                    UserId = 3, UserName = "******", Role = "QA", Enabled = true
                },
            };

            // Setup
            moqIDALContext = new Mock <IDALContext>();
            //moqIDALContext.Setup(db => db.Users).Verifiable();
            // Assert
            _IDALContext = moqIDALContext.Object;
            userService  = new UserService(_IDALContext);
        }
Ejemplo n.º 9
0
        public SendMailViewModel()
        {
            ListaEmails = new List <UserAdressBook>();
            context     = new DALContext();
            try
            {
                if (string.IsNullOrEmpty(LoggerUser))
                {
                    ListaEmails = context.AddressBooks.All().ToList();
                }
                else
                {
                    ListaEmails = context.AddressBooks.All().Where(p => p.Username.ToUpper().Contains(LoggerUser)).ToList();
                }

                if (Order == null)
                {
                    Order       = new Order();
                    Order.Items = new List <OrderProduct>();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 10
0
        public ActionResult IncluirCliente(Model.Entities.Customer Customer)
        {
            try
            {
                context = new DALContext();

                Customer.Document = Customer.Document.Replace(".", "").Replace("-", "").Replace("/", "");

                context.Customers.Create(Customer);
                context.SaveChanges();

                var CustomerList = context.Customers.All()
                                   .Select(p => new
                {
                    p.Id,
                    p.CompanyName
                })
                                   .OrderBy(p => p.CompanyName).ToList();

                var CustomerListJSON = new JavaScriptSerializer().Serialize(CustomerList);

                return(Content(String.Format("{0};{1}", Customer.Id, CustomerListJSON)));
            }
            catch (Exception ex)
            {
                return(Content(ex.Message));
            }
        }
Ejemplo n.º 11
0
        public ActionResult IncluirVendedor(Model.Entities.Vendor Vendor, int CustomerID)
        {
            try
            {
                context = new DALContext();

                context.Vendors.Create(Vendor);
                context.SaveChanges();

                context.VendorsCustomer.Create(new VendorsCustomer()
                {
                    CustomerID = CustomerID,
                    VendorID   = Vendor.Id
                });

                context.SaveChanges();

                var Customer = context.Customers.Find(p => p.Id == CustomerID);

                Customer.VendorId = Vendor.Id;
                context.Customers.Update(Customer);
                context.SaveChanges();

                return(Content(String.Format("{0}", Vendor.Id)));
            }
            catch (Exception ex)
            {
                return(Content(ex.Message));
            }
        }
Ejemplo n.º 12
0
        public ActionResult Carteira()
        {
            context = new DALContext();
            var Orders = context.Orders.Filter(p => p.Status == "PEDIDO - ABERTO").ToList();

            var OrderProducts = new List <OrderProduct>();

            Orders.ForEach(p =>
            {
                OrderProducts.AddRange(p.Items);
            });

            var CustomerList = OrderProducts.Select(p => p.Order.CustomerOrder).Distinct().ToList();
            var ProductList  = OrderProducts.Select(p => p.ProductItem).Distinct().ToList();

            CustomerList.Insert(0, new Customer()
            {
                Id = 0, CompanyName = "TODOS"
            });
            ProductList.Insert(0, new Product()
            {
                Id = 0, Name = "TODOS"
            });

            ViewData["CustomerList"] = CustomerList;
            ViewData["ProductList"]  = ProductList;

            return(View(OrderProducts));
        }
Ejemplo n.º 13
0
        public ActionResult CarregarModalEmail(int OrderID)
        {
            try
            {
                context = new DALContext();
                List <UserAdressBook> Contatos = context.AddressBooks.Filter(p => p.Username == User.Identity.Name).ToList();

                HtmlToPdf converter = new HtmlToPdf();
                ViewBag.ToPDF = "1";
                SelectPdf.PdfDocument doc = converter.ConvertUrl("http://control.gtwave.com.br/Invoice/InvoiceFile?InvoiceID=" + OrderID);

                ViewBag.ToPDF = "0";

                byte[] fileBytes = doc.Save();
                string fileName  = "proposta_" + OrderID.ToString() + ".pdf";
                return(File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, fileName));



                //return Content(String.Format("Arquivo exportado.", OrderID));
            }
            catch (Exception ex)
            {
                return(Content(ex.Message));
            }
        }
Ejemplo n.º 14
0
        public JsonResult GetProducts(int ProductID)
        {
            context = new DALContext();
            var objProduct = context.Products.Find(p => p.Id == ProductID);

            return(Json(objProduct));
        }
Ejemplo n.º 15
0
        public ActionResult FornecedorSave(Provider model)
        {
            context = new DALContext();

            try
            {
                model.RegisterDate     = DateTime.Now;
                model.LastUpdate       = DateTime.Now;
                model.PhoneCode        = 13;
                model.CommercialPolicy = 0;
                model.Discount         = 0;

                if (model.Id > 0)
                {
                    context.Providers.Update(model);
                }
                else
                {
                    context.Providers.Create(model);
                }
                context.SaveChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            ViewBag.Message = "Fornecedor cadastrado com sucesso.";

            return(RedirectToAction("Fornecedores"));
        }
Ejemplo n.º 16
0
        public PartialViewResult LoggedUserPartial()
        {
            try
            {
                Model.Entities.User usuario = new Model.Entities.User();
                context = new DALContext();

                usuario = context.Users.All().SingleOrDefault(p => p.UserName == User.Identity.Name);

                if (usuario.UserName == "*****@*****.**")
                {
                    ViewBag.NomeLogado = "Vilo";
                }
                else
                {
                    ViewBag.NomeLogado = "Uriel Silva";
                }
            }
            catch (Exception ex)
            {
                return(PartialView());
            }

            return(PartialView());
        }
Ejemplo n.º 17
0
        public JsonResult VincularFornecedorProduto(int ProviderID, int ProductID, long codigoProdutoFornecedor, string modeloFabricante)
        {
            try
            {
                context = new DALContext();

                var objProductProvider = new ProductProvider()
                {
                    ProductID     = ProductID,
                    ProviderID    = ProviderID,
                    Code          = codigoProdutoFornecedor,
                    IsActive      = true,
                    ModelProvider = modeloFabricante
                };

                context.ProductProviders.Create(objProductProvider);
                context.SaveChanges();

                return(Json(new { erro = false }));
            }
            catch (Exception ex)
            {
                return(Json(new { erro = true, msg = ex.Message }));
            }
        }
Ejemplo n.º 18
0
        public ClienteViewModel()
        {
            if (Customer == null)
            {
                Customer = new Customer();
            }

            context   = new DALContext();
            Countries = context.Countries.All().OrderBy(p => p.Name).ToList();
            Cities    = new List <City>();
            States    = context.States.All().OrderBy(p => p.Name).ToList();
            States.Insert(0, new State()
            {
                Id = 0, Name = "SELECIONE..."
            });

            CondicoesPagamento = context.PaymentTerms.All().ToList();
            CondicoesPagamento.Insert(0, new PaymentTerm()
            {
                Id = 0, Description = "SELECIONE..."
            });

            ModolidadeTransporte = context.ShippingModes.All().ToList();
            ModolidadeTransporte.Insert(0, new ShippingMode()
            {
                Id = 0, Name = "SELECIONE..."
            });

            Vendedores = context.VendorsCustomer.Filter(p => p.CustomerID == Customer.Id).Select(p => p.Vendor).ToList();
        }
Ejemplo n.º 19
0
        public ActionResult ContatosEmailSave(UserAdressBook model)
        {
            context = new DALContext();

            try
            {
                if (ModelState.IsValid)
                {
                    model.Username = User.Identity.Name;

                    if (model.Id > 0)
                    {
                        context.AddressBooks.Update(model);
                    }
                    else
                    {
                        context.AddressBooks.Create(model);
                    }
                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            ViewBag.Message = "Contato cadastrado com sucesso.";

            return(RedirectToAction("ContatosEmailLista"));
        }
Ejemplo n.º 20
0
        public PartialViewResult ConferenciaGetListaProdtos(int OrderID)
        {
            context = new DALContext();
            var OrderProducts = context.PurchaseOrderItem.Filter(p => p.PurchaseOrderId == OrderID).ToList();

            return(PartialView("_ConferenciaListaProdutos", OrderProducts));
        }
Ejemplo n.º 21
0
        public PartialViewResult GetOrderProducts(int OrderID)
        {
            context = new DALContext();
            var OrderProducts = context.PurchaseOrderItem.All().Include("ProductItem").Where(p => p.PurchaseOrderId == OrderID).ToList();

            return(PartialView("_ListPurchaseOrdemItem", OrderProducts));
        }
Ejemplo n.º 22
0
        public ActionResult Index()
        {
            context = new DALContext();
            var Orders = context.PurchaseOrders.Filter(p => p.Status == "PEDIDO_ABERTO").ToList();

            return(View(Orders));
        }
Ejemplo n.º 23
0
        public ActionResult Edit(int OrderID)
        {
            var model = new Control.UI.Models.PedidoCompraViewModel();

            context = new DALContext();

            PurchaseOrder retorno = new PurchaseOrder();

            try
            {
                retorno = context.PurchaseOrders.All().Include("Items").ToList().Find(p => p.Id == OrderID);

                model.PurchaseOrder       = retorno;
                model.PurchaseOrder.Items = retorno.Items;

                foreach (var item in model.PurchaseOrder.Items)
                {
                    item.ProductItem = new Product();
                    item.ProductItem = context.Products.Find(x => x.Id == item.ProductID);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(View("Create", model));
        }
Ejemplo n.º 24
0
        public JsonResult GetCitiesByState(int StateID)
        {
            context = new DALContext();

            var CityList = context.Cities.All().Where(p => p.StateId == StateID).OrderBy(p => p.Name).ToList();

            return(Json(new { Cidades = CityList }, JsonRequestBehavior.AllowGet));
        }
 public ComponentsElementsController(IDALContext context)
 {
     _componentsElements = context.ComponentsElements;
     _components         = context.Components;
     _elements           = context.Elements;
     _variants           = context.Variants;
     _users = context.Users;
 }
Ejemplo n.º 26
0
        public ActionResult Delete(int OrderID)
        {
            context = new DALContext();
            context.Orders.Delete(p => p.Id == OrderID);
            context.SaveChanges();

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 27
0
        public ActionResult DeletePurchaseOrderItem(int PurchaseOrderItemID)
        {
            context = new DALContext();
            context.PurchaseOrderItem.Delete(p => p.Id == PurchaseOrderItemID);
            context.SaveChanges();

            return(Content("Item Excluído com Sucesso!"));
        }
Ejemplo n.º 28
0
        public ActionResult Delete(int InvoiceID)
        {
            context = new DALContext();
            context.Invoices.Delete(p => p.Id == InvoiceID);
            context.SaveChanges();

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 29
0
        public ActionResult OrdersCustomer(int ClientID)
        {
            context = new DALContext();

            var Orders = context.Orders.Filter(p => p.CustomerID == ClientID).ToList();

            return(View("Index", Orders));
        }
Ejemplo n.º 30
0
        public ActionResult DeleteOrderProduct(int OrderProductID)
        {
            context = new DALContext();
            context.OrdersProducts.Delete(p => p.Id == OrderProductID);
            context.SaveChanges();

            return(Content("Item Excluído com Sucesso!"));
        }
Ejemplo n.º 31
0
        public FeedsService(IDALContext dalContext)
        {
            if (dalContext == null)
            {
                throw new ArgumentNullException("dalContext");
            }

            _dalContext = dalContext;
        }
Ejemplo n.º 32
0
        public TestBussiness()
        {
            user = new User
            {
                UserName = "******",
                Role = "Tester",
                Enabled = true
            };

            var users = new List<User>
            {
                new User{UserId = 1, UserName = "******", Role = "Description",Enabled = true},
                new User{UserId = 2, UserName = "******", Role = "PM",Enabled = true},
                new User{UserId = 3, UserName = "******", Role = "QA",Enabled = true},
            };

            // Setup
            moqIDALContext = new Mock<IDALContext>();
            //moqIDALContext.Setup(db => db.Users).Verifiable();
            // Assert
            _IDALContext = moqIDALContext.Object;
            userService = new UserService(_IDALContext);
        }
Ejemplo n.º 33
0
 public DocumentService(IDALContext context)
 {
     _context = context;
 }
Ejemplo n.º 34
0
 public UserService(IDALContext dal)
 {
     context = dal;
 }
Ejemplo n.º 35
0
 public QueryService(IDALContext dal)
 {
     context = dal;
 }
Ejemplo n.º 36
0
 public BLLService()
 {
     _context = new DALContext();
 }
Ejemplo n.º 37
0
 public UserService(IDALContext context)
 {
     _context = context;
 }
Ejemplo n.º 38
0
 public ClassService(IDALContext contextParam)
 {
     context = contextParam;
 }
Ejemplo n.º 39
0
 public TaskController(IDALContext context)
 {
     _tasks = context.Tasks;
     _users = context.Users;
 }
Ejemplo n.º 40
0
 public ProfileService(IDALContext context)
 {
     _context = context;
 }
 public void TestInitialize()
 {
     _dalContextMock = _mockRepository.StrictMock<IDALContext>();
     _devicesRepository = _mockRepository.StrictMock<IDevicesRepository>();
 }
Ejemplo n.º 42
0
 public BoardService(IDALContext contextParam)
 {
     context = contextParam;
 }
Ejemplo n.º 43
0
 public StatusService(IDALContext dbContext)
 {
     _Dbcontext = dbContext;
 }
Ejemplo n.º 44
0
 public StatusService()
 {
     _Dbcontext = new DALContext();
 }
 public void Initialize()
 {
     _dalContextMock = _mockRepository.StrictMock<IDALContext>();
     _messagesRepositoryMock = _mockRepository.StrictMock<IMessagesRepository>();
     _devicesRepositoryMock = _mockRepository.StrictMock<IDevicesRepository>();
 }
 public void Initialise()
 {
     _dalContext = _mockRepository.StrictMock<IDALContext>();
     _usersRepository = _mockRepository.StrictMock<IUsersRepository>();
     _rolesRepository = _mockRepository.StrictMock<IRolesRepository>();
 }
Ejemplo n.º 47
0
 public PkgOrderService(IDALContext context)
 {
     this.context = context;
 }
Ejemplo n.º 48
0
 public UserService(IDALContext dalContext)
 {
     this.dalContext = dalContext;
 }
Ejemplo n.º 49
0
 public CRMService(IDALContext context)
 {
     this.context = context;
 }
Ejemplo n.º 50
0
 public RoleService(IDALContext context)
 {
     _context = context;
 }
Ejemplo n.º 51
0
 public ProjectService(IDALContext dalContext)
 {
     this.dalContext = dalContext;
 }