示例#1
0
        public IHttpActionResult ClockOutEmployee([FromBody] ClockOutModel clockOut)
        {
            var container = ContainerConfig.Configure();

            User     userQuery     = new User();
            Activity activityQuery = new Activity();

            if (clockOut == null)
            {
                return(Json(new { Result = "Internal server error.", StatusCode = HttpStatusCode.InternalServerError }));
            }

            using (var scope = container.BeginLifetimeScope())
            {
                var app = scope.Resolve <IUserDataAccess>();

                userQuery = app.GetUser(clockOut.UserName);

                if (userQuery == null)
                {
                    return(Json(new { Result = "Employee record not found." }));
                }
            }

            using (var scope = container.BeginLifetimeScope())
            {
                var app = scope.Resolve <IActivityDataAccess>();

                activityQuery = app.GetActivitySingle(clockOut.ActivityId);
                if (activityQuery == null)
                {
                    return(Json(new { Result = "Activity selected is unknown." }));
                }
            }

            using (var scope = container.BeginLifetimeScope())
            {
                var app = scope.Resolve <ITimeOutEmployeeAttendance>();
                ClockOutQueryModel clockQuery = new ClockOutQueryModel
                {
                    UserId           = userQuery.UserKey,
                    UserName         = clockOut.UserName,
                    ActivityId       = activityQuery.ActivityId,
                    ClockOutDateTime = DateTime.Parse(clockOut.ClockOutDateTime)
                };

                string clockOutResult = app.ClockOutEmployee(clockQuery);

                return(Json(new { Result = clockOutResult }));
            }
        }
示例#2
0
        public ActionResult StopClock(ClockOutModel model)
        {
            var    res    = UserService.StopClock(model.Token);
            bool   status = false;
            string resMsg = "";

            switch (res)
            {
            case Enums.ClockActionResponse.ClockStopped:
                status = true;
                resMsg = "Clock stopepd!";
                break;

            case Enums.ClockActionResponse.NoLastClock:
                resMsg = "You dont have last clock!";
                break;

            case Enums.ClockActionResponse.NotLoggedIn:
                resMsg = "You are not logged in!";
                break;
            }
            return(Ok(new { status = status, res = resMsg }));
        }
示例#3
0
        public ActionResult StartClock(ClockOutModel model)
        {
            var    res    = UserService.AddNewClock(model.Token);
            bool   status = false;
            string resMsg = "";

            switch (res)
            {
            case Enums.ClockActionResponse.ClockStarted:
                status = true;
                resMsg = "New clock added";
                break;

            case Enums.ClockActionResponse.AlreadyHasClock:
                resMsg = "You seem to already have an on going clock!";
                break;

            case Enums.ClockActionResponse.NotLoggedIn:
                resMsg = "You are not logged in!";
                break;
            }
            return(Ok(new { status = status, res = resMsg }));
        }