public ActionResult OnPageLoad()
        {
            EmpModelList mainObj = new EmpModelList();
            BLLClass     bllObj  = new BLLClass();

            mainObj.DesnList       = new List <LookupData>();
            mainObj.DeptList       = new List <LookupData>();
            mainObj.SupervisorList = new List <Employee>();
            DtoList list = new DtoList();

            list.DesnList       = new List <LookupDTO>();
            list.DeptList       = new List <LookupDTO>();
            list.SupervisorList = new List <DTOClass>();
            list = bllObj.GetDtoData();
            foreach (var data in list.DesnList)
            {
                LookupData desgObj = new LookupData()
                {
                    Id   = data.Id,
                    Name = data.Name
                };

                mainObj.DesnList.Add(desgObj);
            }

            foreach (var data in list.DeptList)
            {
                LookupData deptObj = new LookupData()
                {
                    Id   = data.Id,
                    Name = data.Name
                };

                mainObj.DeptList.Add(deptObj);
            }

            foreach (var data in list.SupervisorList)
            {
                Employee superObj = new Employee()
                {
                    Id         = data.Id,
                    Supervisor = data.Supervisor
                };

                mainObj.SupervisorList.Add(superObj);
            }

            return(View(mainObj));
        }
        public List <ItemCategoryDto> getShopItemsForFirstLoad(long id)
        {
            List <ItemCategoryDto> DtoList;

            using (EAharaDB context = new EAharaDB())
            {
                var shop = context.Shops.FirstOrDefault(x => x.Id == id);
                var data = context.ItemCategories.Where(x => x.IsActive == true && context.Items.Where(y => y.ItemCategoryId == x.Id && y.IsActive && y.Shop.ShopCategoryId == shop.ShopCategoryId && y.ShopId == id).Count() > 0)
                           .Select(x => new ItemCategoryDto
                {
                    Id       = x.Id,
                    IsActive = x.IsActive,
                    Priority = x.Priority,
                    Name     = x.Name,
                    Image    = x.Image,
                    Items    = context.Items.Where(y => y.IsActive && y.ShopId == id && y.ItemCategoryId == x.Id).Select(
                        y => new ItemDto {
                        Id         = y.Id,
                        IsActive   = y.IsActive,
                        Name       = y.Name,
                        OfferId    = y.OfferId,
                        OfferPrice = y.OfferPrice,
                        Price      = y.Price,
                        Image      = y.Image,
                        InActive   = y.InActive,
                        Preference = y.Preference,
                        Quantity   = 1,
                        Offer      = new OfferDto
                        {
                            Id         = y.Offer != null ? y.Offer.Id : 0,
                            Image      = y.Offer != null ? y.Offer.Image : "",
                            Tittle     = y.Offer != null ? y.Offer.Tittle : "",
                            Percentage = y.Offer != null ? y.Offer.Percentage : 0,
                        },
                    }).OrderBy(y => y.OfferPrice).ToList(),
                }).ToList();

                DtoList = data;

                var dataoffer = context.Items.Where(x => x.IsActive && x.ShopId == id && x.OfferId != null)
                                .Select(x => new ItemDto
                {
                    Id             = x.Id,
                    Name           = x.Name,
                    IsActive       = x.IsActive,
                    Image          = x.Image,
                    TagLine        = x.TagLine,
                    Description    = x.Description,
                    Price          = x.Price,
                    ShopId         = x.ShopId,
                    ItemCategoryId = x.ItemCategoryId,
                    OfferId        = x.OfferId,
                    OfferPrice     = x.OfferPrice,
                    InActive       = x.InActive,
                    Preference     = x.Preference,
                    Quantity       = 1,
                    Offer          = new OfferDto
                    {
                        Image      = x.Offer != null ? x.Offer.Image : "",
                        Percentage = x.Offer != null ? x.Offer.Percentage : 0,
                        Tittle     = x.Offer != null ? x.Offer.Tittle : "",
                        Id         = x.Offer != null ? x.Offer.Id : 0,
                    },
                    Shop = new ShopDto
                    {
                        Name           = x.Shop.Name,
                        Id             = x.Shop.Id,
                        DeliveryCharge = x.Shop.DeliveryCharge,
                    },
                    ItemsCategory = new ItemCategoryDto
                    {
                        Name = x.ItemsCategory.Name,
                        Id   = x.ItemsCategory.Id,
                    }
                }).OrderBy(x => x.OfferPrice).ToList();

                if (dataoffer.Count() > 0)
                {
                    ItemCategoryDto temp = new ItemCategoryDto();
                    temp.Name     = "Today's Offers";
                    temp.Priority = 0;
                    temp.Items    = new List <ItemDto>();
                    foreach (var offer in dataoffer)
                    {
                        temp.Items.Add(offer);
                    }
                    DtoList.Add(temp);
                }
            }
            return(DtoList);
        }
Exemplo n.º 3
0
        // public static List<DTOClass> listDto;

        public DtoList GetDtoData()
        {
            try
            {
                DALClass Obj     = new DALClass();
                DtoList  listDto = new DtoList();
                listDto.Emplist = new List <DTOClass>();
                EmpEntityList emp = Obj.GetAllDetails();
                foreach (var data in emp.Emplist)
                {
                    DTOClass dt = new DTOClass
                    {
                        Id           = data.Id,
                        Name         = data.Name,
                        DesgnationId = data.DesgnationId,
                        Designation  = data.Designation,
                        Gender       = data.Gender,
                        DepartmentId = data.DepartmentId,
                        Department   = data.Department,
                        Experience   = data.Experience,
                        Skills       = data.Skills,
                        EmailId      = data.EmailId,
                        ContactNo    = data.ContactNo,
                        SupervisorId = data.SupervisorId,
                        Supervisor   = data.Supervisor,
                        DateOfBirth  = data.DateOfBirth,
                        Address      = data.Address,
                        InsertedBy   = data.InsertedBy,
                        InsertedOn   = data.InsertedOn,
                        UpdatedBy    = data.UpdatedBy,
                        UpdatedOn    = data.UpdatedOn
                    };
                    listDto.Emplist.Add(dt);
                }

                listDto.DesnList = new List <LookupDTO>();
                foreach (var data in emp.DesnList)
                {
                    LookupDTO desgObj = new LookupDTO()
                    {
                        Id   = data.Id,
                        Name = data.Name
                    };
                    listDto.DesnList.Add(desgObj);
                }

                listDto.DeptList = new List <LookupDTO>();
                foreach (var data in emp.DeptList)
                {
                    LookupDTO deptObj = new LookupDTO()
                    {
                        Id   = data.Id,
                        Name = data.Name
                    };

                    listDto.DeptList.Add(deptObj);
                }
                listDto.SupervisorList = new List <DTOClass>();
                int c = emp.SupervisorList.Count();

                foreach (var data in emp.SupervisorList)
                {
                    DTOClass superObj = new DTOClass()
                    {
                        Id         = data.Id,
                        Supervisor = data.Supervisor
                    };
                    listDto.SupervisorList.Add(superObj);
                }
                return(listDto);
            }
            catch
            {
                return(null);
            }
        }