Exemplo n.º 1
0
        public ActionResult Add(SupervisorViewModel model)
        {
            AlertMessage alert = new AlertMessage();

            SupervisorBusiness business = new SupervisorBusiness();

            if (!ModelState.IsValid)
            {
                alert.Text = string.Join(System.Environment.NewLine, ModelState.Values
                                         .SelectMany(v => v.Errors)
                                         .Select(e => e.ErrorMessage));
            }
            else
            {
                business.SetUserAuth(ViewBag.UserAuth);

                alert = business.Add(model);
            }

            TempData["AlertMessage"] = alert;

            if (alert.Status == 1)
            {
                return(RedirectToAction("Index"));
            }

            ViewBag.ListRayonType = business.GetListRayonType();

            return(View("Edit", model));
        }
Exemplo n.º 2
0
        private SupervisorViewModel GetSupervisorViewModel(DataRow dr)
        {
            SupervisorViewModel model = new SupervisorViewModel();

            model.NIK                    = dr.IsNull("NIK") ? 0 : Convert.ToInt32(dr["NIK"]);
            model.Fullname               = dr.IsNull("FullName") ? null : dr["FullName"].ToString();
            model.IsRole                 = dr.IsNull("Role") ? false : Convert.ToBoolean(dr["Role"]);
            model.DefaultRayonType       = dr.IsNull("DefaultRayonType") ? null : dr["DefaultRayonType"].ToString();
            model.AllowWriteBy           = dr.IsNull("AllowedByNIK") ? (int?)null : Convert.ToInt32(dr["AllowedByNIK"]);
            model.IsAbleToUpload         = model.AllowWriteBy == null ? false : true;
            model.UploadValidTo          = dr.IsNull("UploadValidTo") ? (DateTime?)null : Convert.ToDateTime(dr["UploadValidTo"]);
            model.FormattedUploadValidTo = model.UploadValidTo == null ? "" : model.UploadValidTo.Value.ToString(AppConstant.DefaultFormatDate);

            if (!dr.IsNull("ValidFrom"))
            {
                model.ValidFromDate      = Convert.ToDateTime(dr["ValidFrom"]);
                model.FormattedValidFrom = model.ValidFromDate.ToString(AppConstant.DefaultFormatDate);
            }

            if (!dr.IsNull("ValidTo"))
            {
                model.ValidToDate      = Convert.ToDateTime(dr["ValidTo"]);
                model.FormattedValidTo = model.ValidToDate.ToString(AppConstant.DefaultFormatDate);
            }

            return(model);
        }
Exemplo n.º 3
0
        public IActionResult Edit(SupervisorViewModel model)
        {
            var response = ResponseModelFactory.CreateInstance;

            if (ConfigurationManager.AppSettings.IsTrialVersion)
            {
                response.SetIsTrial();
                return(Ok(response));
            }
            using (_dbContext)
            {
                var entity = _dbContext.SystemUser.FirstOrDefault(x => x.SystemUserUuid == model.SystemUserUuid);
                entity.RealName      = model.RealName; //督导员姓名
                entity.Sex           = model.Sex;      //性别
                entity.Phone         = model.Phone;    //联系方式
                entity.GrabageRoomId = model.garbageRoomUuid;
                if (model.InTime != null)
                {
                    entity.InTime = DateTime.Parse(model.InTime).ToString("yyyy-MM-dd");//入职时间
                }
                else
                {
                    entity.InTime = DateTime.Now.ToString("yyyy-MM-dd");
                }
                var entitys = _dbContext.GrabageRoom.FirstOrDefault(x => x.GarbageRoomUuid == model.garbageRoomUuid);
                entity.VillageId = entitys.VillageId;
                entity.ZaiGang   = model.ZaiGang;//是否在职
                //entity.SystemRoleUuid = model.SystemRoleUUid;
                _dbContext.SaveChanges();
                return(Ok(response));
            }
        }
        /// <summary>
        /// 显示督导信息总览表
        /// </summary>
        /// <param name="page"></param>
        /// <returns></returns>
        public PartialViewResult SupervisorList(int page = 1)
        {
            List <SupervisorViewModel> spvlist = new List <SupervisorViewModel>();

            foreach (TeachersModel teacher in teacherlist)
            {
                SupervisorViewModel m = new SupervisorViewModel();
                m.Tid         = teacher.Tid;
                m.TeacherName = teacher.TeacherName;
                m.Phone       = teacher.Phone;
                m.Password    = teacher.Password;
                m.SpareTime   = "";
                var sptlist = (from s in splist
                               where s.Tid == teacher.Tid
                               select s).ToList();
                if (sptlist.Count > 0)
                {
                    List <SpareTimeModel> sptlist1 = new List <SpareTimeModel>();
                    sptlist1 = sptlist.GroupBy(a => a.Week).Select(b => b.First()).ToList();
                    foreach (SpareTimeModel spt in sptlist1)
                    {
                        m.SpareTime = m.SpareTime + " " + spt.Week.ToString();
                    }
                }
                else
                {
                    m.SpareTime = "未填写";
                }
                spvlist.Add(m);
            }

            IPagedList <SupervisorViewModel> Iteachers = spvlist.ToPagedList(page, 10);

            return(PartialView(Iteachers));
        }
        // GET: Supervisor/Edit/5
        public ActionResult Edit(int id)
        {
            Supervisor          supervisor = db.Supervisors.Find(id);
            SupervisorViewModel model      = Mapper.Map <Supervisor, SupervisorViewModel>(supervisor);

            return(View(model));
        }
 public ActionResult Create(SupervisorViewModel model)
 {
     if (ModelState.IsValid)
     {
         Supervisor supervisor = Mapper.Map <SupervisorViewModel, Supervisor>(model);
         db.Supervisors.Add(supervisor);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(model));
 }
 public ActionResult Edit(SupervisorViewModel model)
 {
     if (ModelState.IsValid)
     {
         Supervisor supervisor = Mapper.Map <SupervisorViewModel, Supervisor>(model);
         db.Entry(supervisor).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(model));
 }
        // The details action allow displaying the details of a selected item by Id in the supervisor table/model
        // GET: Supervisor/Details/5
        public ActionResult Details(int id)
        {
            Supervisor supervisor = db.Supervisors.Find(id);
            var        model      = new SupervisorViewModel
            {
                SupervisorId = supervisor.SupervisorId,
                FirstName    = supervisor.FirstName,
                LastName     = supervisor.LastName,
                Email        = supervisor.Email,
                Phone        = supervisor.Phone,
                Mobile       = supervisor.Mobile,
                Department   = supervisor.Department,
            };

            return(View(model));
        }
Exemplo n.º 9
0
        private SupervisorViewModel GetSupervisorViewModel(RHHeader item)
        {
            SupervisorViewModel model = new SupervisorViewModel()
            {
                NIK              = item.FSSObj1.NIK,
                Fullname         = item.FSSObj1.FullName,
                IsRole           = item.FSSObj1.Role,
                DefaultRayonType = item.FSSObj1.DefaultRayonType,
                ValidFromDate    = item.ValidFrom,
                ValidToDate      = item.ValidTo
            };

            model.FormattedValidFrom = item.ValidFrom.ToString(AppConstant.DefaultFormatDate);
            model.FormattedValidTo   = item.ValidTo.ToString(AppConstant.DefaultFormatDate);

            return(model);
        }
Exemplo n.º 10
0
        private SupervisorViewModel GetSupervisorViewModel(FSS item)
        {
            SupervisorViewModel model = new SupervisorViewModel();

            model.NIK                    = item.NIK;
            model.Fullname               = item.FullName;
            model.IsRole                 = item.Role;
            model.DefaultRayonType       = item.DefaultRayonType;
            model.AllowWriteBy           = item.AllowedByNIK;
            model.IsAbleToUpload         = item.AllowedByNIK == null ? false : true;
            model.UploadValidTo          = item.UploadValidTo;
            model.FormattedUploadValidTo = model.UploadValidTo == null ? null : model.UploadValidTo.Value.ToString(AppConstant.DefaultFormatDate);

            model.ValidFromDate = item.ValidFrom;
            model.ValidToDate   = item.ValidTo;

            model.FormattedValidFrom = model.ValidFromDate.ToString(AppConstant.DefaultFormatDate);
            model.FormattedValidTo   = model.ValidToDate.ToString(AppConstant.DefaultFormatDate);

            return(model);
        }
Exemplo n.º 11
0
        public static List <SupervisorViewModel> GeSupervisors()
        {
            List <SupervisorViewModel> dtEmployees = new List <SupervisorViewModel>();
            EmployeeMasterReportAccess access      = new EmployeeMasterReportAccess();
            DataTable dtResult = access.getEmployeeReportToOrgChart();
            Random    random   = new Random();

            foreach (DataRow dtr in dtResult.Rows)
            {
                SupervisorViewModel item = new SupervisorViewModel
                {
                    SYS_EMPID   = dtr["SYS_EMPID"].ToString() + random.Next(8, 10).ToString(),
                    DEPTCODEGEO = dtr["DEPTCODEGEO"].ToString(),
                    EMPID       = dtr["EMPID"].ToString(),
                    IMAGE       = dtr["IMAGE"].ToString(),
                    EMPNAME     = dtr["EMPNAME"].ToString(),
                    EMAIL       = dtr["EMAIL"].ToString(),
                    POSITION    = dtr["POSITION"].ToString()
                };
                dtEmployees.Add(item);
            }
            return(dtEmployees);
        }
        public async Task <ActionResult> SupervisorsList(SupervisorsPageViewModel vm)
        {
            if (string.IsNullOrEmpty(vm.SelectedMerchant))
            {
                return(this.JsonFailResult(Phrases.FieldShouldNotBeEmpty, "#selectedMerchant"));
            }

            var staffs = await _payInvoiceClient.GetEmployeesAsync(vm.SelectedMerchant);

            var filteredstaffs = new List <SupervisorViewModel>();

            foreach (var staff in staffs)
            {
                MerchantsSupervisorMembershipResponse supervisor =
                    await _payInternalClient.GetSupervisorMembershipWithMerchantsAsync(staff.Id);

                if (supervisor != null)
                {
                    var item = new SupervisorViewModel()
                    {
                        Id                   = staff.Id,
                        Email                = staff.Email,
                        FirstName            = staff.FirstName,
                        LastName             = staff.LastName,
                        SupervisingMerchants = supervisor.Merchants.ToList()
                    };
                    filteredstaffs.Add(item);
                }
            }
            var viewModel = new SupervisorsListViewModel
            {
                Employees        = filteredstaffs,
                SelectedMerchant = vm.SelectedMerchant
            };

            return(View(viewModel));
        }
Exemplo n.º 13
0
        public ActionResult Edit(int?id)
        {
            ViewBag.IsEdit = true;

            if (id == null)
            {
                return(RedirectToAction("Index"));
            }

            SupervisorBusiness business = new SupervisorBusiness();

            SupervisorViewModel model = business.GetDetail(id.Value);

            if (model == null)
            {
                TempData["AlertMessage"] = new AlertMessage(StaticMessage.ERR_DATA_NOT_FOUND);

                return(RedirectToAction("Index"));
            }

            ViewBag.ListRayonType = business.GetListRayonType();

            return(View(model));
        }
Exemplo n.º 14
0
        public AlertMessage Edit(SupervisorViewModel model)
        {
            AlertMessage alert = new AlertMessage();

            if (!IsAccessible(ModuleCode.Supervisor))
            {
                alert.Text = StaticMessage.ERR_ACCESS_DENIED;
                return(alert);
            }

            if (!IsEditable())
            {
                alert.Text = StaticMessage.ERR_ACCESS_DENIED;
                return(alert);
            }

            IRepository <FSS> repo = _unitOfWork.GetRepository <FSS>();

            repo.Condition = PredicateBuilder.True <FSS>().And(x => x.NIK == model.NIK);

            FSS item = repo.Find().FirstOrDefault();

            if (item == null)
            {
                alert.Text = StaticMessage.ERR_DATA_NOT_FOUND;
                return(alert);
            }

            DateTime now = DateTime.UtcNow.ToUtcID();

            item.FullName = model.Fullname;
            //item.Role = model.IsRole;
            item.DefaultRayonType = model.DefaultRayonType;
            item.ValidFrom        = DateTime.Parse(model.FormattedValidFrom);
            item.ValidTo          = DateTime.Parse(model.FormattedValidTo);
            item.UpdatedBy        = _userAuth.NIK.ToString();
            item.UpdatedOn        = now;

            try
            {
                _unitOfWork.BeginTransaction();

                repo.Update(item);

                _unitOfWork.Commit();

                alert.Status = 1;
                alert.Text   = string.Format(StaticMessage.SCS_EDIT, item.NIK, item.FullName);
            }
            catch (Exception ex)
            {
                _logger.Write("error", DateTime.Now, ex.Message, _userAuth.Fullname, ex);
                alert.Text = StaticMessage.ERR_SAVE_FAILED;
            }
            finally
            {
                _unitOfWork.Dispose();
            }

            return(alert);
        }
Exemplo n.º 15
0
 protected virtual void OnAttached(object svm)
 {
     this.Supervisor = (SupervisorViewModel)svm;
 }
 private void LsvSkippedCases_Loaded(object sender, RoutedEventArgs e)
 {
     lsvSkippedCases.DataContext = SupervisorViewModel.GetSkippedCases();
 }
Exemplo n.º 17
0
        public AlertMessage Add(SupervisorViewModel model)
        {
            AlertMessage alert = new AlertMessage();

            if (!IsAccessible(ModuleCode.Supervisor))
            {
                alert.Text = StaticMessage.ERR_ACCESS_DENIED;
                return(alert);
            }

            if (!IsEditable())
            {
                alert.Text = StaticMessage.ERR_ACCESS_DENIED;
                return(alert);
            }

            //model.ValidFromDate = DateTime.ParseExact(model.FormattedValidFrom, AppConstant.DefaultFormatDate, _cultureInfo);
            //model.ValidToDate = DateTime.ParseExact(model.FormattedValidTo, AppConstant.DefaultFormatDate, _cultureInfo);

            IRepository <FSS> repo = _unitOfWork.GetRepository <FSS>();
            FSS item = null;

            repo.Condition = PredicateBuilder.True <FSS>().And(x => x.NIK == model.NIK);

            item = repo.Find().FirstOrDefault();

            if (item != null)
            {
                alert.Text = string.Format(StaticMessage.ERR_NIK_EXIST, model.NIK);
                return(alert);
            }

            DateTime now       = DateTime.UtcNow.ToUtcID();
            DateTime validFrom = now.AddMonths(-1).AddDays(1).Date;
            DateTime validTo   = new DateTime(9999, 12, 31);

            item = new FSS()
            {
                NIK              = model.NIK,
                FullName         = model.Fullname,
                Role             = model.IsRole,
                DefaultRayonType = model.DefaultRayonType,
                ValidFrom        = validFrom,
                ValidTo          = validTo,
                CreatedBy        = _userAuth.NIK.ToString(),
                CreatedOn        = now,
                UpdatedBy        = _userAuth.NIK.ToString(),
                UpdatedOn        = now,
            };

            try
            {
                _unitOfWork.BeginTransaction();

                repo.Insert(item);

                _unitOfWork.Commit();

                alert.Status = 1;
                alert.Text   = string.Format(StaticMessage.SCS_ADD_MASTER, model.NIK, model.Fullname);
            }
            catch (Exception ex)
            {
                _logger.Write("error", DateTime.Now, ex.Message, _userAuth.Fullname, ex);
                alert.Text = StaticMessage.ERR_SAVE_FAILED;
            }
            finally
            {
                _unitOfWork.Dispose();
            }

            return(alert);
        }
Exemplo n.º 18
0
        public IActionResult Create(SupervisorViewModel model)
        {
            var response = ResponseModelFactory.CreateInstance;

            if (model.garbageRoomUuid.ToString() == "")
            {
                response.SetFailed("请选择垃圾厢房");
                return(Ok(response));
            }
            using (_dbContext)
            {
                //先判断是不是数据库里已经存在的用户
                if (_dbContext.SystemUser.Count(x => x.Phone == model.Phone) > 0)
                {
                    //已经是数据库里的用户就添加督导员身份
                    var ent = _dbContext.SystemUser.FirstOrDefault(x => x.Phone == model.Phone && x.IsDeleted == 0);
                    ent.SystemRoleUuid = ent.SystemRoleUuid.TrimEnd(',') + ",c678d6e6-1c04-47d3-8660-2e4457504ee9";
                    ent.RealName       = model.RealName;
                    ent.Sex            = model.Sex;
                    ent.GrabageRoomId  = model.garbageRoomUuid;
                    var entitys = _dbContext.GrabageRoom.FirstOrDefault(x => x.GarbageRoomUuid == model.garbageRoomUuid);
                    ent.VillageId = entitys.VillageId;
                    if (model.InTime != "")
                    {
                        ent.InTime = DateTime.Parse(model.InTime).ToString("yyyy-MM-dd");//入职时间
                    }
                    else
                    {
                        ent.InTime = DateTime.Now.ToString("yyyy-MM-dd");
                    }
                    ent.ZaiGang = model.ZaiGang;
                    _dbContext.SaveChanges();
                }
                else
                {
                    if (_dbContext.SystemUser.Where(x => x.IsDeleted == 0).Count(x => x.Phone == model.Phone) > 0)
                    {
                        response.SetFailed("该用户已存在");
                        return(Ok(response));
                    }
                    var entity = new HaikanRefuseClassification.Api.Entities.SystemUser();
                    entity.SystemUserUuid = Guid.NewGuid();
                    entity.RealName       = model.RealName;//督导员姓名
                    entity.Sex            = model.Sex;
                    entity.Phone          = model.Phone;
                    entity.GrabageRoomId  = model.garbageRoomUuid;
                    if (model.InTime != "")
                    {
                        entity.InTime = DateTime.Parse(model.InTime).ToString("yyyy-MM-dd");//入职时间
                    }
                    else
                    {
                        entity.InTime = DateTime.Now.ToString("yyyy-MM-dd");
                    }
                    entity.AddPeople      = AuthContextService.CurrentUser.DisplayName;//添加人
                    entity.SystemRoleUuid = "c678d6e6-1c04-47d3-8660-2e4457504ee9";
                    entity.UserType       = 5;
                    entity.ZaiGang        = model.ZaiGang;//在职默认1在岗
                    entity.IsDeleted      = 0;
                    var entitys = _dbContext.GrabageRoom.FirstOrDefault(x => x.GarbageRoomUuid == model.garbageRoomUuid);
                    entity.VillageId = entitys.VillageId;
                    entity.AddTime   = DateTime.Now.ToString("yyyy-MM-dd");
                    _dbContext.SystemUser.Add(entity);
                    _dbContext.SaveChanges();
                }
                response.SetSuccess("添加成功");
                return(Ok(response));
            }
        }