예제 #1
0
        public ActionResult AddRoleWorkingTime(int currentOffset, string StoreID, string StoreName)
        {
            InteRoleWorkingTime model = new InteRoleWorkingTime();

            model.GetListRole(StoreID, CurrentUser.ListOrganizationId);
            model.OffSet      = currentOffset;
            model.StoreName   = StoreName;
            model.StoreID     = StoreID;
            model.IsWithPoins = CurrentUser.listStore.Where(x => x.ID == StoreID).FirstOrDefault().IsWithPoins;
            model.ListWorkingTime.ForEach(x => x.StoreID = StoreID);
            return(PartialView("_RoleWorkingTime", model));
        }
예제 #2
0
        public InteEmployeeModels GetDetailView(string id, string StoreId)
        {
            try
            {
                InteEmployeeModels model = new InteEmployeeModels();
                var listEmp = _factory.GetListEmployee(null, id);
                if (listEmp != null && listEmp.Any())
                {
                    model = listEmp.FirstOrDefault();
                }
                model.ImageURL  = string.IsNullOrEmpty(model.ImageURL) ? Commons.Image100_100 : model.ImageURL;
                model.HiredDate = model.HiredDate.ToLocalTime();
                model.BirthDate = model.BirthDate.ToLocalTime();

                //==========
                InteRoleWorkingTime rWorkingTime = null;
                if (model.ListEmpStore != null && model.ListEmpStore.Any())
                {
                    // If case View, only get store info with id = StoreId
                    var emp = model.ListEmpStore.Where(w => w.StoreID == StoreId).FirstOrDefault();

                    if (emp != null)
                    {
                        model.StoreID     = emp.StoreID;
                        model.StoreName   = emp.StoreName;
                        model.IsWithPoins = CurrentUser.listStore.Where(x => x.ID == model.StoreID).FirstOrDefault().IsWithPoins;
                        model.IsSyncPoins = emp.IsSyncPoins;
                        model.RoleID      = emp.RoleID;
                        model.RoleName    = emp.RoleName;

                        //===========
                        rWorkingTime = new InteRoleWorkingTime();
                        rWorkingTime.ListWorkingTime.Clear();

                        rWorkingTime.OffSet = 0;
                        rWorkingTime.Status = (int)Commons.EStatus.Actived;

                        rWorkingTime.RoleID   = emp.RoleID;
                        rWorkingTime.RoleName = emp.RoleName;

                        rWorkingTime.StoreID   = emp.StoreID;
                        rWorkingTime.StoreName = emp.StoreName;

                        rWorkingTime.GetListRole(rWorkingTime.StoreID, CurrentUser.ListOrganizationId);

                        //============
                        var lstStore = (SelectList)ViewBag.StoreID;
                        model.ListStore = lstStore.ToList();
                        foreach (var item in model.ListStore)
                        {
                            item.Disabled = model.ListEmpStore.Where(x => x.StoreID.Equals(item.Value)).FirstOrDefault() == null ? false : true;
                            item.Selected = model.ListEmpStore.Where(x => x.StoreID.Equals(item.Value)).FirstOrDefault() == null ? false : true;
                        }

                        if (model.ListWorkingTime != null)
                        {
                            foreach (var itemStore in model.ListWorkingTime)
                            {
                                if (string.IsNullOrEmpty(itemStore.StoreID))
                                {
                                    itemStore.StoreID = emp.StoreID;
                                }
                            }
                            //=========
                            var lstWorkingTime = model.ListWorkingTime.Where(x => x.StoreID.Equals(emp.StoreID)).OrderBy(x => x.Day).ToList();
                            for (int i = 0; i < lstWorkingTime.Count; i++)
                            {
                                var item = lstWorkingTime[i];
                                if (item.IsOffline)
                                {
                                    item.From = CurrentUser.GetLanguageTextFromKey("OFF");
                                    item.To   = CurrentUser.GetLanguageTextFromKey("OFF");
                                }
                                else
                                {
                                    item.From = item.FromTime.ToLocalTime().ToString("HH:mm");
                                    item.To   = item.ToTime.ToLocalTime().ToString("HH:mm");
                                }
                                switch (item.Day)
                                {
                                case 2:
                                    item.StrDate = CurrentUser.GetLanguageTextFromKey("Mon");
                                    break;

                                case 3:
                                    item.StrDate = CurrentUser.GetLanguageTextFromKey("Tue");
                                    break;

                                case 4:
                                    item.StrDate = CurrentUser.GetLanguageTextFromKey("Wed");
                                    break;

                                case 5:
                                    item.StrDate = CurrentUser.GetLanguageTextFromKey("Thu");
                                    break;

                                case 6:
                                    item.StrDate = CurrentUser.GetLanguageTextFromKey("Fri");
                                    break;

                                case 7:
                                    item.StrDate = CurrentUser.GetLanguageTextFromKey("Sat");
                                    break;

                                case 8:
                                    item.StrDate = CurrentUser.GetLanguageTextFromKey("Sun");
                                    break;
                                }
                                rWorkingTime.ListWorkingTime.Add(item);
                            }
                        }
                        model.ListRoleWorkingTime.Add(rWorkingTime);
                    }
                }
                return(model);
            }
            catch (Exception ex)
            {
                _logger.Error("Employee_Detail_View: " + ex);
                return(null);
            }
        }