Пример #1
0
        // Get RentalItem
        public RentalItemResponse GetRentalItem(RentalItemRequest request)
        {
            var response = new RentalItemResponse();

            #region *** Intercepted Method ***
            // Try to add renteditem from AlienDB to Nexus if the item already exist then try to refresh the information
            request.RentalItemId = SaveRentalItem(new RentalItemRequest { RentalItem = _rentalItemAdapter.GetRentalItem(request).RentalItem }).RentalItemId;

            #endregion

            // Validate if the item is from Nexus
            if (request.RentalItemId > 0)
            {
                var itemFound = Olympus._Enterprise.RentalItems.Where(x => x.Id == request.RentalItemId).SingleOrDefault();
                response.RentalItem = Mapper.Map<RentalItemDto>(itemFound);
            }
            return response;
        }
Пример #2
0
        // Save Item
        public RentalItemResponse SaveRentalItem(RentalItemRequest request)
        {
            var response = new RentalItemResponse();

            if (request.RentalItem != null)
            {
                RentalItem rentalItem = null;
                // Check if Edit or Add
                if (request.RentalItem.Id > 0)
                {
                    // Edit
                    rentalItem = Olympus._Enterprise.RentalItems.Where(x => x.Id == request.RentalItem.Id).SingleOrDefault();

                    if (rentalItem != null)
                    {
                        // Overrides the DateCreated
                        request.RentalItem.DateCreated = rentalItem.DateCreated;
                        Mapper.Map(request.RentalItem, rentalItem);
                    }
                }
                else
                {
                    // Add
                    if (request.RentalItem.Code != null)
                    {
                        // Check some info from AlienDB
                        rentalItem = new RentalItem();
                        Mapper.Map(request.RentalItem, rentalItem);
                        Olympus._Enterprise.RentalItems.AddObject(rentalItem);
                    }
                }
                Olympus._Enterprise.SaveChanges();
                if (rentalItem != null) response.RentalItemId = rentalItem.Id;
            }
            return response;
        }
Пример #3
0
        // Get Item from Alien DB
        public RentalItemResponse GetRentalItem(RentalItemRequest request)
        {
            var response = new RentalItemResponse();
            if (request.RentalItem != null)
            {
                // Check for update an item
                if (request.RentalItemId > 0)
                {
                    #region Update Data
                    // Search the item to update data
                    var bindedItemFound = Asgard._Foreing.ALQ_INVENTARIO
                        .Where(x => x.INV_Codigo.ToUpper() == request.RentalItem.Code.ToUpper())
                        .FirstOrDefault();

                    if (bindedItemFound != null)
                    {
                        // Create an object to be mapped later
                        response.RentalItem = new RentalItemDto
                                                  {
                                                      Id = request.RentalItemId,
                                                      Code = bindedItemFound.INV_Codigo.Trim(),
                                                      Name = bindedItemFound.INV_Nombre.Trim(),
                                                      Cost = Convert.ToDecimal(bindedItemFound.INV_Costo),
                                                      Price = Convert.ToDecimal(bindedItemFound.INV_Precio),
                                                      MonthlyPrice = Convert.ToDecimal(bindedItemFound.INV_Precio_Mes),
                                                      FortnightPrice = Convert.ToDecimal(bindedItemFound.INV_Precio_Quincena),
                                                      WeeklyPrice = Convert.ToDecimal(bindedItemFound.INV_Precio_Semana),
                                                      DailyPrice = Convert.ToDecimal(bindedItemFound.INV_Precio_Dia),
                                                      MaximunDiscount = 0,
                                                      FamilyId = 0,
                                                      IsTaxed = Convert.ToBoolean(bindedItemFound.INV_Con_Imp_Ventas),
                                                      DateModified = DateTime.Now,
                                                      WasDeleted = false
                                                  };
                        // get the stocks by Warehouse missing
                    }
                    #endregion
                }
                else
                {
                    #region Get Item
                    // Search the item
                    var itemFound = Asgard._Foreing.ALQ_INVENTARIO.Where(x => x.INV_Codigo.ToUpper() == request.RentalItem.Code.ToUpper()).
                            FirstOrDefault();
                    if (itemFound != null)
                    {
                        response.RentalItem = new RentalItemDto
                                            {
                                                Code = itemFound.INV_Codigo.Trim(),
                                                Name = itemFound.INV_Nombre.Trim(),
                                                Cost = Convert.ToDecimal(itemFound.INV_Costo),
                                                Price = Convert.ToDecimal(itemFound.INV_Precio),
                                                MonthlyPrice = Convert.ToDecimal(itemFound.INV_Precio_Mes),
                                                FortnightPrice = Convert.ToDecimal(itemFound.INV_Precio_Quincena),
                                                WeeklyPrice = Convert.ToDecimal(itemFound.INV_Precio_Semana),
                                                DailyPrice = Convert.ToDecimal(itemFound.INV_Precio_Dia),
                                                MaximunDiscount = 0,
                                                FamilyId = 0,
                                                IsTaxed = Convert.ToBoolean(itemFound.INV_Con_Imp_Ventas),
                                                DateCreated = DateTime.Now,
                                                DateModified = DateTime.Now,
                                                WasDeleted = false
                                            };
                        // get the storage by Warehouse missing
                    }
                    #endregion
                }
            }
            return response;
        }
Пример #4
0
        // Add aditional results to the search
        public void SearchRentalItem(RentalItemRequest request, RentalItemResponse response)
        {
            var maximunResultRows = Convert.ToInt32(Resources.MaximunSearchResults);

            // Apply the search with the pattern given
            var searchResults = Asgard._Foreing.ALQ_INVENTARIO
                .Where(x => x.INV_Nombre.ToUpper().Contains(request.SearchRentalItemQuery.ToUpper()) ||
                            x.INV_Codigo.ToUpper().Contains(request.SearchRentalItemQuery.ToUpper()))
                            .OrderBy(y => y.INV_Nombre)
                            .Take(maximunResultRows).ToList();

            // Fill the response with the result found
            foreach (var rentalItem in searchResults)
            {
                // Check if the rentalItem is already binded
                var bindedRentalItem = response.RentalItemList.Where(x => x.Code == rentalItem.INV_Codigo).FirstOrDefault();
                if (bindedRentalItem == null)
                {
                    var rentealItemDto = new RentalItemDto
                    {
                        Code = rentalItem.INV_Codigo.Trim(),
                        Name = rentalItem.INV_Nombre.Trim(),
                        Cost = Convert.ToDecimal(rentalItem.INV_Costo),
                        Price = Convert.ToDecimal(rentalItem.INV_Precio),
                        MonthlyPrice = Convert.ToDecimal(rentalItem.INV_Precio_Mes),
                        FortnightPrice = Convert.ToDecimal(rentalItem.INV_Precio_Quincena),
                        WeeklyPrice = Convert.ToDecimal(rentalItem.INV_Precio_Semana),
                        DailyPrice = Convert.ToDecimal(rentalItem.INV_Precio_Dia),
                        MaximunDiscount = 0,
                        FamilyId = 0,
                        Storages = new Collection<StorageDto>()
                    };
                    rentealItemDto.Storages.Add(new StorageDto
                    {
                        Available = Convert.ToDecimal(rentalItem.INV_Disponible),
                        Quantity = Convert.ToDecimal(rentalItem.INV_Existencia),
                    });
                    response.RentalItemList.Add(rentealItemDto);
                }
                else
                {
                    bindedRentalItem.Name = rentalItem.INV_Nombre.Trim();
                    bindedRentalItem.Cost = Convert.ToDecimal(rentalItem.INV_Costo);
                    bindedRentalItem.Price = Convert.ToDecimal(rentalItem.INV_Precio);
                    bindedRentalItem.MonthlyPrice = Convert.ToDecimal(rentalItem.INV_Precio_Mes);
                    bindedRentalItem.FortnightPrice = Convert.ToDecimal(rentalItem.INV_Precio_Quincena);
                    bindedRentalItem.WeeklyPrice = Convert.ToDecimal(rentalItem.INV_Precio_Semana);
                    bindedRentalItem.DailyPrice = Convert.ToDecimal(rentalItem.INV_Precio_Dia);
                    bindedRentalItem.MaximunDiscount = 0;
                    bindedRentalItem.FamilyId = 0;
                    bindedRentalItem.Storages = new Collection<StorageDto>();
                }

            }
        }
Пример #5
0
 private void Search(string query)
 {
     var request = new RentalItemRequest { SearchRentalItemQuery = query};
     ShowSearchResults(new RentalItemFactory().SearchRentalItem(request).RentalItemList);
 }
Пример #6
0
 // Search
 public RentalItemResponse SearchRentalItem(RentalItemRequest request)
 {
     return _rentalItemService.SearchRentalItem(request);
 }
Пример #7
0
 // Get
 public RentalItemResponse GetRentalItem(RentalItemRequest request)
 {
     return _rentalItemService.GetRentalItem(request);
 }
Пример #8
0
        // Search Item
        public RentalItemResponse SearchRentalItem(RentalItemRequest request)
        {
            var response = new RentalItemResponse { RentalItemList = new List<RentalItemDto>() };

            // Search item
            var itemsFound = Olympus._Enterprise.RentalItems.Where(x => x.Name.Contains(request.SearchRentalItemQuery) ||
                             x.Code.Contains(request.SearchRentalItemQuery))
                             .OrderBy(y => y.Name)
                             .Take(Convert.ToInt32(Properties.Resources.MaximunResultRows))
                             .Distinct()
                             .ToList();

            if (itemsFound.Count > 0)
            {
                response.RentalItemList = Mapper.Map<List<RentalItemDto>>(itemsFound);
            }

            // Intercepted Method
            _rentalItemAdapter.SearchRentalItem(request, response);

            // Sorted again the list
            response.RentalItemList = response.RentalItemList.OrderBy(x => x.Name).ToList();

            return response;
        }