Exemple #1
0
        public async Task UpdateRestItemSalesPrice(List <RestItemsListDto> NonSchesrestitems, int RestInfoID)
        {
            var RestNonSchesItem = _RestNonSchItemRepository.GetAll().Where(a => a.RestInfoID == RestInfoID).ToList();

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

            var restitems = _RestItemRepository.GetAll().Where(p => p.IsDeleted == false).OrderBy(p => p.ItemDesc).ToList();

            List <RestItemsListDto> restitemListDtos = ObjectMapper.Map <List <RestItemsListDto> >(restitems).OrderBy(a => a.Id).ToList();

            for (int i = 0; i < NonSchesrestitems.Count(); i++)
            {
                for (int n = 0; n < restitemListDtos.Count; n++)
                {
                    if (NonSchesrestitems[i].Id == restitemListDtos[n].Id)
                    {
                        if (NonSchesrestitems[i].SalesPrice != restitemListDtos[n].SalesPrice)
                        {
                            RestNonSchItem update = RestNonScheItemListDtos.Find(a => a.RestItemId == NonSchesrestitems[i].Id);

                            update.SpecialSalesPrice = NonSchesrestitems[i].SalesPrice;

                            await _RestNonSchItemRepository.UpdateAsync(update);
                        }
                    }
                }
            }
        }
        public async Task SelectRestReqScheItem(List <RestItemsListDto> input, int RestRequestsId, int?RestSchedulesId, int?RestInfosID)
        {
            try
            {
                if (input.Count() > 0)
                {
                    for (int i = 0; i < input.Count(); i++)
                    {
                        if (input[i].Count > 0)
                        {
                            RestScheduleItem ScheduleItem = _RestScheduleItemRepository.GetAll().Where(a => a.RestItemsId == input[i].Id && a.RestSchedulesId == RestSchedulesId).FirstOrDefault();

                            if (ScheduleItem != null)
                            {
                                var reqitem = new RestRequestItem();

                                reqitem.RestScheduleItemsId = ScheduleItem.Id;
                                reqitem.RestRequestsId      = RestRequestsId;
                                reqitem.Count = input[i].Count;

                                await _RestRequestItemRepository.InsertAsync(reqitem);
                            }
                            else
                            {
                                RestNonSchItem RestNonSchItem = _RestNonSchItemRepository.GetAll().Where(a => a.RestItemId == input[i].Id && a.RestInfoID == RestInfosID).FirstOrDefault();


                                var reqitem = new RestRequestItem();

                                reqitem.RestNonSchItemId = RestNonSchItem.Id;
                                reqitem.RestRequestsId   = RestRequestsId;
                                reqitem.Count            = input[i].Count;

                                await _RestRequestItemRepository.InsertAsync(reqitem);
                            }
                        }
                        await CurrentUnitOfWork.SaveChangesAsync();
                    }
                }
            }
            catch (DbUpdateException e)
            {
                SqlException s = e.InnerException.InnerException as SqlException;
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemple #3
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)
            {
            }
        }
        //[AbpAuthorize(AppPermissions.Pages_Tenant_RestaurantReq_EditRestReq)]
        public GetRestReqForEditOutput GetRestReqForEdit(GetRestReqForEditInput input)
        {
            RestSchedule   RestSches    = new RestSchedule();
            RestNonSchItem RestNonSches = new RestNonSchItem();

            var RestReq = _RestReqRepository.Get(input.Id);

            GetRestReqForEditOutput req = ObjectMapper.Map <GetRestReqForEditOutput>(RestReq);

            RestSches = _RestSchRepository.GetAll().Where(a => a.Id == req.RestSchedulesId).SingleOrDefault();

            RestNonSches = _RestNonSchItemRepository.GetAll().Where(a => a.Id == req.RestNonSchItemID).SingleOrDefault();

            var RestInfos = _RestInfoRepository.GetAll().Where(a => a.Id == req.RestInfosID).SingleOrDefault();

            var RestCategoryDesc = _RestCategoryRepository.GetAll().Where(a => a.Id == RestInfos.RestCategoryId).Select(a => a.RestCategoryDesc).SingleOrDefault();

            req.RestaurantInfo = RestInfos.Area + " - " + RestInfos.Building + " - " + " / " + RestCategoryDesc;

            req.Username = _EmployeesViewRepository.GetAll().Where(a => a.emp_id == RestReq.UserId).Select(a => a.emp_username).FirstOrDefault();

            if (RestSches != null)
            {
                req.RestInfosID = RestSches.RestInfoID;

                req.Day = RestSches.Day;

                req.Date = RestSches.CurrentDate.ToString("dd-MM-yyyy");
            }

            req.GetDates = GetDates(req.RestInfosID);

            req.SelectedRestItems = GetRestSchItems(req.RestSchedulesId, "", input.Id);

            return(req);
        }
Exemple #5
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));
        }