public ActionResult Search(InteEmployeeViewModels model)
 {
     try
     {
         var data = _factory.GetListEmployee(model.StoreID, null, CurrentUser.ListOrganizationId);
         data.ForEach(x => x.ImageURL = string.IsNullOrEmpty(x.ImageURL) ? Commons.Image100_100 : x.ImageURL);
         model.ListItem = data;
     }
     catch (Exception e)
     {
         _logger.Error("Employee Add Company Search: " + e);
         return(new HttpStatusCodeResult(400, e.Message));
     }
     return(PartialView("_ListData", model));
 }
Пример #2
0
        public ActionResult Search(InteEmployeeViewModels model)
        {
            try
            {
                var data   = _factory.GetListEmployee(model.StoreID, null, CurrentUser.ListOrganizationId);
                var data02 = new List <InteEmployeeModels>();
                foreach (var item in data)
                {
                    item.ImageURL = string.IsNullOrEmpty(item.ImageURL) ? Commons.Image100_100 : item.ImageURL;
                    if (item.ListEmpStore != null && item.ListEmpStore.Count > 0)
                    {
                        item.StoreName = item.ListEmpStore[0].StoreName;
                        item.RoleName  = item.ListEmpStore[0].RoleName;
                        item.StoreID   = item.ListEmpStore[0].StoreID;
                        item.RoleID    = item.ListEmpStore[0].RoleID;
                    }
                    //======
                    if (item.ListEmpStore != null && item.ListEmpStore.Count > 1)
                    {
                        InteEmployeeModels emp = null;
                        for (int i = item.ListEmpStore.Count - 1; i >= 1; i--)
                        {
                            InteEmployeeOnStoreModels empOnStore = item.ListEmpStore[i];

                            List <InteEmployeeOnStoreModels> ListEmpStore = new List <InteEmployeeOnStoreModels>();
                            ListEmpStore.Add(new InteEmployeeOnStoreModels
                            {
                                EmployeeID = item.ID,
                                RoleID     = empOnStore.RoleID,
                                RoleName   = empOnStore.RoleName,
                                StoreID    = empOnStore.StoreID,
                                StoreName  = empOnStore.StoreName
                            });

                            emp = new InteEmployeeModels()
                            {
                                BirthDate       = item.BirthDate,
                                City            = item.City,
                                Country         = item.Country,
                                Email           = item.Email,
                                Gender          = item.Gender,
                                HiredDate       = item.HiredDate,
                                ID              = item.ID,
                                ImageURL        = item.ImageURL,
                                IsActive        = item.IsActive,
                                ListMarital     = item.ListMarital,
                                ListRole        = item.ListRole,
                                ListWorkingTime = item.ListWorkingTime,
                                Marital         = item.Marital,
                                Mode            = item.Mode,
                                Name            = item.Name,
                                Phone           = item.Phone,
                                Pincode         = item.Pincode,

                                RoleName     = empOnStore.RoleName,
                                StoreName    = empOnStore.StoreName,
                                StoreID      = empOnStore.StoreID,
                                RoleID       = empOnStore.RoleID,
                                ListEmpStore = ListEmpStore,

                                Street    = item.Street,
                                TimeItems = item.TimeItems,
                                Zipcode   = item.Zipcode
                            };

                            data02.Add(emp);
                            //item.ListEmpStore.Remove(empOnStore);
                        }
                    }
                }
                data.AddRange(data02);
                if (model.ListStores != null && model.ListStores.Count > 0)
                {
                    if (data != null && data.Count > 0)
                    {
                        data = data.Where(x => model.ListStores.Contains(x.StoreID)).ToList();
                    }
                }
                model.ListItem = data;
            }
            catch (Exception e)
            {
                _logger.Error("Employee_Search: " + e);
                return(new HttpStatusCodeResult(400, e.Message));
            }
            return(PartialView("_ListData", model));
        }