Exemplo n.º 1
0
        public async Task UnAttachRestNonScheItem(List <RestItemsListDto> selecteditem, int RestInfoID)
        {
            try
            {
                var RestNonSchesItem = _RestNonSchItemRepository.GetAll().Where(a => a.RestInfoID == RestInfoID).ToList();

                List <RestNonSchItem> RestNonScheItemListDtos = ObjectMapper.Map <List <RestNonSchItem> >(RestNonSchesItem);

                if (selecteditem != null)
                {
                    if (selecteditem.Count > 0)
                    {
                        for (int i = 0; i < selecteditem.Count(); i++)
                        {
                            RestNonSchItem add = RestNonScheItemListDtos.Find(a => a.RestItemId == selecteditem[i].Id);

                            if (add == null)
                            {
                                RestNonSchItem item = new RestNonSchItem();
                                item.RestInfoID = RestInfoID;
                                item.RestItemId = selecteditem[i].Id;

                                await _RestNonSchItemRepository.InsertAsync(item);
                            }
                        }
                    }
                }
                if (RestNonScheItemListDtos != null)
                {
                    if (RestNonScheItemListDtos.Count() > 0)
                    {
                        for (int i = 0; i < RestNonScheItemListDtos.Count(); i++)
                        {
                            RestItemsListDto remove = selecteditem.Find(a => a.Id == RestNonScheItemListDtos[i].RestItemId);

                            if (remove == null)
                            {
                                await _RestNonSchItemRepository.DeleteAsync(RestNonScheItemListDtos[i].Id);
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
            }
        }
        public RestItemsListDto GetRestItem(int RestItemId, int RestInfoId)
        {
            var Restitem = _RestItemRepository.GetAll().Where(a => a.Id == RestItemId).SingleOrDefault();

            RestItemsListDto RestItems = ObjectMapper.Map <RestItemsListDto>(Restitem);

            var RestNonSchItem = _RestNonSchItemRepository.GetAll().Where(a => a.RestItemId == RestItemId && a.RestInfoID == RestInfoId && a.IsDeleted == false).FirstOrDefault();

            if (RestNonSchItem != null)
            {
                if (RestItems.SalesPrice != RestNonSchItem.SpecialSalesPrice && RestNonSchItem.SpecialSalesPrice != 0)
                {
                    RestItems.SalesPrice = RestNonSchItem.SpecialSalesPrice;
                }
            }

            return(RestItems);
        }
        public List <RestItemsListDto> GetNonScheRestItems(int RestInfoID, string filter)
        {
            List <RestItemsListDto> restitemListDtos = new List <RestItemsListDto>();

            List <RestNonSchesListDto> RestNonSchesListDto = new List <RestNonSchesListDto>();

            try
            {
                var RestNonSchItem = _RestNonSchItemRepository.GetAll().Where(a => a.RestInfoID == RestInfoID && a.IsDeleted == false).ToList();

                RestNonSchesListDto = ObjectMapper.Map <List <RestNonSchesListDto> >(RestNonSchItem);

                for (int i = 0; i < RestNonSchesListDto.Count(); i++)
                {
                    int RestItemId = RestNonSchesListDto[i].RestItemId;

                    RestItem restitems = _RestItemRepository.GetAll().Where(a => a.Id == RestItemId ||
                                                                            a.ItemDesc.Contains(filter) ||
                                                                            a.ItemsCategory.CategoryDesc.Contains(filter) ||
                                                                            a.SalesPrice.ToString().Contains(filter)).SingleOrDefault();

                    RestItemsListDto restitem = ObjectMapper.Map <RestItemsListDto>(restitems);

                    if (RestNonSchesListDto[i].SpecialSalesPrice > 0 &&
                        restitem.SalesPrice != RestNonSchesListDto[i].SpecialSalesPrice && restitem != null)
                    {
                        restitem.SalesPrice = RestNonSchesListDto[i].SpecialSalesPrice;
                    }
                    if (restitem != null)
                    {
                        var ItemCategoryDesc = _ItemsCategoryRepository.GetAll().Where(a => a.Id == restitem.ItemsCategoryId).SingleOrDefault();
                        restitem.ItemsCategoryDesc = ItemCategoryDesc.CategoryDesc;

                        restitemListDtos.Add(restitem);
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            return(new List <RestItemsListDto>(restitemListDtos));
        }
Exemplo n.º 4
0
        public List <RestItemsListDto> GetRestSchItems(GetRestReqSchInput input)
        {
            List <RestItemsListDto> ItemsList = new List <RestItemsListDto>();

            try
            {
                RestNonSchItem Nonschitem = new RestNonSchItem();

                RestItemsListDto Items = new RestItemsListDto();

                RestRequest RestReq = _RestReqRepository.GetAll().Where(a => a.Id == input.Id).SingleOrDefault();

                var RestReqitem = _RestRequestItemRepository.GetAll().Where(a => a.RestRequestsId == input.Id).ToList();

                List <RestReqItemListDto> RestReqItemListDtos = ObjectMapper.Map <List <RestReqItemListDto> >(RestReqitem);

                List <RestScheduleItem> schitems = _RestScheduleItemRepository.GetAll().Where(a => a.RestSchedulesId == RestReq.RestSchedulesId).ToList();

                foreach (RestReqItemListDto reqitem in RestReqItemListDtos)
                {
                    Nonschitem = _RestNonSchItemRepository.GetAll().Where(a => a.Id == reqitem.RestNonSchItemId).SingleOrDefault();
                }

                if (schitems.Count() > 0)
                {
                    foreach (RestScheduleItem item in schitems)
                    {
                        RestItem items = _RestItemRepository.GetAll().Where(a => a.Id == item.RestItemsId).SingleOrDefault();

                        Items = ObjectMapper.Map <RestItemsListDto>(items);

                        foreach (RestReqItemListDto reqitem in RestReqItemListDtos)
                        {
                            if (item.Id == reqitem.RestScheduleItemsId)
                            {
                                Items.Count = reqitem.Count;

                                if (reqitem.Count > 0)
                                {
                                    Items.RestRequestItemsId = reqitem.Id;
                                }

                                var RestResponse = _RestRespRepository.GetAll().Where(a => a.RestRequestItemsId == reqitem.Id).ToList();

                                List <RestRespListDto> RestRespListDtos = ObjectMapper.Map <List <RestRespListDto> >(RestResponse);

                                foreach (RestRespListDto restrsp in RestRespListDtos)
                                {
                                    if (restrsp.RestRequestItemsId == reqitem.Id)
                                    {
                                        Items.NotAvailable = restrsp.NotAvailable;
                                    }
                                }
                                ItemsList.Add(Items);
                            }
                        }
                    }
                }

                if (Nonschitem != null)
                {
                    foreach (RestReqItemListDto reqitem in RestReqItemListDtos)
                    {
                        Nonschitem = _RestNonSchItemRepository.GetAll().Where(a => a.Id == reqitem.RestNonSchItemId).SingleOrDefault();

                        RestItem items = _RestItemRepository.GetAll().Where(a => a.Id == Nonschitem.RestItemId).SingleOrDefault();

                        Items = ObjectMapper.Map <RestItemsListDto>(items);

                        Items.Count = reqitem.Count;

                        if (reqitem.Count > 0)
                        {
                            Items.RestRequestItemsId = reqitem.Id;
                        }

                        var RestResponse = _RestRespRepository.GetAll().Where(a => a.RestRequestItemsId == reqitem.Id).SingleOrDefault();

                        if (RestResponse != null)
                        {
                            if (RestResponse.RestRequestItemsId == reqitem.Id)
                            {
                                Items.NotAvailable = RestResponse.NotAvailable;
                            }
                        }
                        ItemsList.Add(Items);
                    }
                }
            }
            catch (Exception e)
            {
            }
            return(new List <RestItemsListDto>(ItemsList));
        }
        public List <RestItemsListDto> GetRestSchItems(int RestSchedulesId, string filter, int RestRequestsId)
        {
            List <RestItemsListDto> ItemsList = new List <RestItemsListDto>();

            try
            {
                RestItemsListDto Items = new RestItemsListDto();

                List <RestScheduleItem> schitems = _RestScheduleItemRepository.GetAll().Where(a => a.RestSchedulesId == RestSchedulesId).ToList();

                var restreq = _RestReqRepository.GetAll().Where(a => a.Id == RestRequestsId).SingleOrDefault();

                var restreqitems = _RestRequestItemRepository.GetAll().Where(a => a.RestRequestsId == RestRequestsId).ToList();

                if (filter != null && filter != "")
                {
                    List <RestItem> FilterItemsList = _RestItemRepository.GetAll().Where(a => a.ItemDesc.Contains(filter) ||
                                                                                         a.ItemsCategory.CategoryDesc.Contains(filter) ||
                                                                                         a.SalesPrice.ToString().Contains(filter)).ToList();

                    ItemsList = ObjectMapper.Map <List <RestItemsListDto> >(FilterItemsList);
                }
                else
                {
                    foreach (RestScheduleItem schitem in schitems)
                    {
                        RestItem items = _RestItemRepository.GetAll().Where(a => a.Id == schitem.RestItemsId && a.IsDeleted == false).SingleOrDefault();

                        Items = ObjectMapper.Map <RestItemsListDto>(items);

                        if (Items != null)
                        {
                            ItemsList.Add(Items);
                        }

                        foreach (var ItemCategory in ItemsList)
                        {
                            var ItemCategoryDesc = _ItemsCategoryRepository.GetAll().Where(a => a.Id == ItemCategory.ItemsCategoryId).SingleOrDefault();
                            ItemCategory.ItemsCategoryDesc = ItemCategoryDesc.CategoryDesc;
                        }

                        if (restreqitems.Count() > 0)
                        {
                            foreach (var reqitem in restreqitems)
                            {
                                if (reqitem.RestNonSchItemId != 0 && reqitem.RestNonSchItemId != null)
                                {
                                    var RestNonSchesItem = _RestNonSchItemRepository.GetAll().Where(a => a.Id == reqitem.RestNonSchItemId && a.RestInfoID == restreq.RestInfosID && a.IsDeleted == false).SingleOrDefault();
                                    var RestItem         = _RestItemRepository.GetAll().Where(a => a.Id == RestNonSchesItem.RestItemId && a.IsDeleted == false).SingleOrDefault();

                                    var RestItemdto = ObjectMapper.Map <RestItemsListDto>(RestItem);
                                    RestItemdto.Count             = reqitem.Count;
                                    RestItemdto.ItemsCategoryDesc = _ItemsCategoryRepository.GetAll().Where(a => a.Id == RestItem.ItemsCategoryId && a.IsDeleted == false).Select(a => a.CategoryDesc).SingleOrDefault();
                                    RestItemdto.NotAvailable      = _RestRespRepository.GetAll().Where(a => a.RestRequestItemsId == reqitem.Id).Select(a => a.NotAvailable).SingleOrDefault();
                                    RestItemdto.RestNonSchId      = RestNonSchesItem.Id;

                                    RestItemsListDto exist = ItemsList.Find(a => a.Id == RestItemdto.Id &&
                                                                            a.RestRequestItemsId == RestItemdto.RestRequestItemsId);

                                    if (exist != null)
                                    {
                                        ItemsList.Remove(exist);
                                        ItemsList.Add(RestItemdto);
                                    }
                                }
                                else if (reqitem.RestScheduleItemsId != 0 && reqitem.RestScheduleItemsId != null)
                                {
                                    var RestScheduleItems = _RestScheduleItemRepository.GetAll().Include(a => a.RestSchedules).Where(a => a.Id == reqitem.RestScheduleItemsId && a.RestSchedules.RestInfoID == restreq.RestInfosID && a.IsDeleted == false).SingleOrDefault();
                                    var RestItem          = _RestItemRepository.GetAll().Where(a => a.Id == RestScheduleItems.RestItemsId && a.IsDeleted == false).SingleOrDefault();

                                    var RestItemdto = ObjectMapper.Map <RestItemsListDto>(RestItem);

                                    RestItemdto.Count             = reqitem.Count;
                                    RestItemdto.ItemsCategoryDesc = _ItemsCategoryRepository.GetAll().Where(a => a.Id == RestItem.ItemsCategoryId && a.IsDeleted == false).Select(a => a.CategoryDesc).SingleOrDefault();
                                    RestItemdto.NotAvailable      = _RestRespRepository.GetAll().Where(a => a.RestRequestItemsId == reqitem.Id).Select(a => a.NotAvailable).SingleOrDefault();
                                    RestItemdto.RestSchedulesId   = RestScheduleItems.RestSchedulesId;

                                    RestItemsListDto exist = ItemsList.Find(a => a.Id == RestItemdto.Id &&
                                                                            a.RestRequestItemsId == RestItemdto.RestRequestItemsId);

                                    if (exist != null)
                                    {
                                        ItemsList.Remove(exist);
                                        ItemsList.Add(RestItemdto);
                                    }
                                }
                            }
                        }
                    }
                }

                return(new List <RestItemsListDto>(ItemsList));
            }
            catch (Exception e)
            {
            }

            return(new List <RestItemsListDto>(ItemsList));
        }