public ActionResult Assign(int waid, int wsiid, string userName)
        {
            WorkerSignin   signin     = wsiServ.Get(wsiid);
            WorkAssignment assignment = waServ.Get(waid);

            waServ.Assign(assignment, signin, userName);

            return(Json(new
            {
                jobSuccess = true
            }));
        }
 public void Create_WSI_deduplicate_succeeds()
 {
     //
     //Arrange
     int fakeid = 12345;
     IQueryable<WorkerSignin> wsiList = new WorkerSignin[] {
         new WorkerSignin() {dwccardnum = 12345, dateforsignin = DateTime.Today}
     }.AsQueryable();
     var _serv = new WorkerSigninService(_wsiRepo.Object, _wRepo.Object, _iRepo.Object, _wrRepo.Object, _wcache.Object, _uow.Object);
     var _signin = new WorkerSignin() { dwccardnum = fakeid, dateforsignin = DateTime.Today };
     WorkerSignin _cbsignin = null;
     _wsiRepo.Setup(s => s.Add(It.IsAny<WorkerSignin>())).Callback((WorkerSignin s) => { _cbsignin = s; });
     _wsiRepo.Setup(s => s.GetAllQ()).Returns(wsiList);
     //
     //Act
     try
     {
         _serv.CreateSignin(_signin, "UnitTest");
     }
     catch(InvalidOperationException ex)
     {
         Console.WriteLine(fakeid.ToString() + ex.Message);
     }
     //
     //Assert
     Assert.IsNull(_cbsignin);
     Assert.IsNull(_signin.Createdby);
 }
 public void Create_WSI_with_worker_match_succeeds()
 {
     //
     //Arrange
     int fakeid = 66666;
     var _serv = new WorkerSigninService(_wsiRepo.Object, _wRepo.Object, _iRepo.Object, _wrRepo.Object,_wcache.Object, _uow.Object);
     var _signin = new WorkerSignin() { dwccardnum = fakeid, dateforsignin = DateTime.Today };
     WorkerSignin _cbsignin = new WorkerSignin();
     _wsiRepo.Setup(s => s.Add(It.IsAny<WorkerSignin>())).Callback((WorkerSignin s) => { _cbsignin = s; });
     //
     //Act
     _serv.CreateSignin(_signin, "UnitTest");
     //
     //Assert
     Assert.AreEqual(_signin, _cbsignin);
     Assert.IsNotNull(_signin.dwccardnum);
     Assert.AreEqual(_signin.dwccardnum, fakeid);
 }
Ejemplo n.º 4
0
 public wsiView(Person per, WorkerSignin sign)
     : base(per, sign)
 {
     lotterySequence = sign.lottery_sequence;
     englishlevel = p == null ? 0 : p.Worker.englishlevelID;
     waid = sign.WorkAssignmentID;
     skill1 = p == null ? null : p.Worker.skill1;
     skill2 = p == null ? null : p.Worker.skill2;
     skill3 = p == null ? null : p.Worker.skill3;
     typeOfWorkID = p == null ? 0 : p.Worker.typeOfWorkID;
 }
Ejemplo n.º 5
0
        public ActionResult lotterySignin(int lotterycardnum, string lotterysignindate, string userName)
        {
            DateTime signinDate = DateTime.MinValue;
            //var workOrder = woServ.GetWorkOrder(id);
            if (System.String.IsNullOrEmpty(lotterysignindate)) throw new ArgumentNullException("Lottery Sign-in date null or empty");
            signinDate = DateTime.Parse(lotterysignindate);

            string rtnstatus;
            var wsi = _serv.GetSignin(lotterycardnum, signinDate);
            if (wsi == null) throw new ArgumentNullException("Lottery cannot find Sign-in record to update");

            if (wsi.lottery_timestamp == null)
            {
                wsi.lottery_sequence = _serv.GetNextLotterySequence(signinDate);
                wsi.lottery_timestamp = DateTime.Now;
                _serv.Save(wsi, userName);
            }
            rtnstatus = "OK";
            var _signin = new WorkerSignin();
            return Json(new
            {
                status = rtnstatus,
                memberID = lotterycardnum
            },
            JsonRequestBehavior.AllowGet);
        }
Ejemplo n.º 6
0
        public ActionResult Index(int dwccardnum, DateTime dateforsignin)
        {
            Worker worker = _wServ.GetWorkerByNum(dwccardnum);
            if (worker == null) throw new NullReferenceException("Card ID doesn't match a worker!");
            var _signin = new WorkerSignin();
            string result = "";
            // The card just swiped
            _signin.dwccardnum = dwccardnum;
            _signin.dateforsignin = new DateTime(dateforsignin.Year, dateforsignin.Month, dateforsignin.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);
            _signin.memberStatus = worker.memberStatus;
            //
            //
            try
            {
                _serv.CreateSignin(_signin, this.User.Identity.Name);
            }
            catch(InvalidOperationException eek)
            {
                result = dwccardnum.ToString() + " " + eek.Message;
            }

            //Get picture from checkin, show with next view
            Image checkin_image = _serv.getImage(dwccardnum);
            string imageRef = "/Content/images/NO-IMAGE-AVAILABLE.jpg";
            if (checkin_image != null)
            {
                imageRef = "/Image/GetImage/" + checkin_image.ID;
            }

            if (result.Length == 0)
                result = "Success!";

            return Json(new
            {
                memberExpired = worker.isExpired,
                memberInactive = worker.isInactive,
                memberSanctioned = worker.isSanctioned,
                memberExpelled = worker.isExpelled,
                message = result,
                imageRef = imageRef,
                expirationDate = worker.memberexpirationdate
            },
            JsonRequestBehavior.AllowGet);
        }