示例#1
0
        public ActionResult StaffInfo(Staff staff, string ButtonType)
        {
            if (ButtonType == "Reset")
            {
                var NewModel = new Entity.Staff();
                ModelState.Clear();
                return(View(NewModel));
            }

            else if (ButtonType == "Next")
            {
                if (ModelState.IsValid)
                {
                    var updated_staff = _service.Find(staff.ID);
                    updated_staff.FName           = staff.FName;
                    updated_staff.MName           = staff.MName;
                    updated_staff.LName           = staff.LName;
                    updated_staff.DOB             = staff.DOB;
                    updated_staff.Address.Subcity = staff.Address.Subcity;
                    updated_staff.Address.Woreda  = staff.Address.Woreda;
                    updated_staff.Address.H_NO    = staff.Address.H_NO;
                    updated_staff.Address.Email   = staff.Address.Email;
                    updated_staff.Address.PhoneBooks.First().Phone = staff.Address.PhoneBooks.First().Phone;

                    CurrentStaff = updated_staff;
                    ModelState.Clear();

                    return(View("UserRegistration", CurrentUserModel));
                }
            }


            return(View());
        }
示例#2
0
        public async Task <ActionResult> ConfirmStaff(Entity.Staff staff)
        {
            staff = _unitOfWork.Staffs.Find(staff.ID);


            staff.Status = BLL.Constants.StaffStatus.CONFIRMED;
            _staffService.Update(staff);
            //if (staff.StaffType == BLL.Constants.StaffTypes.TEACHER)
            //{
            //    var teacher = new Entity.Teacher();
            //    teacher.Staff = staff;
            //     _unitOfWork.Teachers.Add(teacher);
            //}



            try
            {
                await _unitOfWork.SaveAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
            }
            return(Content(""));
        }
示例#3
0
        public Staff login(string mail)
        {
            SqlConnection con = DbConnect.GetConnection();

            con.Open();
            string     sql = "SELECT accountID,account,role,staffName,status FROM Account WHERE account=@account";
            SqlCommand cmd = new SqlCommand(sql, con);

            cmd.Parameters.Add("account", SqlDbType.NVarChar);
            cmd.Parameters["account"].Value = mail;
            SqlDataReader dr = cmd.ExecuteReader();

            Entity.Staff st = null;
            dr.Read();
            st = new Entity.Staff();
            if (dr.HasRows)
            {
                st.accountID = (int)dr["accountID"];
                st.account   = dr["account"].ToString();
                st.role      = dr["role"].ToString();
                st.staffName = dr["staffName"].ToString();
                st.status    = dr["status"].ToString();
                dr.Close();
            }
            else
            {
                return(null);
            }

            con.Close();
            return(st);
        }
示例#4
0
        public override Guid Insert(Entity.Staff entity)
        {
            var guid = base.Insert(entity);

            MemoryData.Current.ReloadStaffs();
            return(guid);
        }
示例#5
0
        public void StaffAddTest()
        {
            var context = new LR.Repositories.DataContext();

            var list = new List <LR.Entity.Staff>();

            string name  = "李四";
            int    index = 0;
            Random r     = new Random();

            LR.Entity.Staff staff = null;
            for (int i = 0; i < 10; i++)
            {
                staff = new Entity.Staff
                {
                    ID         = Guid.NewGuid(),
                    Name       = $"{name}{index++}",
                    ReferrerID = staff?.ID ?? new Guid()
                };
                list.Add(staff);
                list.Add(new Entity.Staff
                {
                    ID         = Guid.NewGuid(),
                    Name       = $"{name}{index++}",
                    ReferrerID = staff.ID
                });
                if (r.Next(0, 2) == 1)
                {
                    list.Add(staff = new Entity.Staff
                    {
                        ID         = Guid.NewGuid(),
                        Name       = $"{name}{index++}",
                        ReferrerID = staff.ID
                    });
                }
            }


            context.Staffs.InsertRange(list.Select(p =>
            {
                p.IdenNo   = "";
                p.MobileNo = "";
                p.State    = Entity.DataState.Normal;
                return(p);
            }).ToArray());

            Assert.IsTrue(context.Staffs.Count(p => true) > 0);
        }
示例#6
0
        public async Task <ActionResult> Claim(Models.Staff.StaffClaimViewModel staffClaimModel)
        {
            if (ModelState.IsValid)
            {
                Entity.Staff staff = AutoMapper.Mapper.Map <Models.Staff.StaffClaimViewModel, Entity.Staff>(staffClaimModel);
                staff.Status     = BLL.Constants.StaffStatus.PENDING;
                staff.Claim_Date = DateTime.Today;
                _service.Insert(staff);

                try
                {
                    await _unitOfWork.SaveAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                }


                return(View("SuccessClaim"));
            }

            return(View());
        }