Example #1
0
        public bool LogTime(LogTimeRequest request)
        {
            var conn           = GetConnection(ConnectionNames.CSPSqlDatabase);
            var commandWrapper = GetStoredProcCommand("dbo.Insert_Clients_Times", conn);

            AddInParameter(commandWrapper, "@CustomerID", DbType.Int32, request.ClientId);
            AddInParameter(commandWrapper, "@UserId", DbType.Int32, request.UserId);
            AddInParameter(commandWrapper, "@Time", DbType.Decimal, request.Time);

            AddInParameter(commandWrapper, "@ERROR", DbType.String, 1000);
            AddInParameter(commandWrapper, "@ERROR_CODE", DbType.String, 4);

            try
            {
                conn.Open();
                int results = commandWrapper.ExecuteNonQuery();

                var isProcedureSucced = Convert.ToBoolean(results);
                MakeDboLog(request.ToString(), isProcedureSucced.ToString(), "dbo.Insert_Clients_Times");

                var errorObject     = GetParameterValue(commandWrapper, "@ERROR");
                var errorCodeObject = GetParameterValue(commandWrapper, "@ERROR_CODE");

                return(Convert.ToBoolean(results));
            }
            finally
            {
                commandWrapper.Dispose();
                conn.Close();
            }
        }
Example #2
0
 public async Task LogOutTime(LogTimeRequest request)
 {
     if (!await CheckIsPublicHolidayOrWeekend((DateTime)request.LogTime, request.OverrideHolidays))
     {
         _repository.InsertLogTime((DateTime)request.LogTime, LogAction.LogOut.ToString());
     }
 }
        public IActionResult PostUpdateTime(int id, [FromBody] LogTimeRequest request)
        {
            if (request == null || request?.LogTime == null)
            {
                request.LogTime = DateTime.Now.ToLocalTime();
            }

            _timeLoggerService.UpdateTime(id, request);

            return(Ok());
        }
        public async Task <IActionResult> PostOutTime([FromBody] LogTimeRequest request)
        {
            if (request == null || request?.LogTime == null)
            {
                request.LogTime = DateTime.Now.ToLocalTime();
            }

            await _timeLoggerService.LogOutTime(request);

            return(Ok());
        }
        public LogTimeRequest GetLogTimeRequest(int clientId, decimal time, int userId, Role role, int teamId)
        {
            var request = new LogTimeRequest
            {
                ClientId   = clientId,
                Time       = time,
                UserId     = userId,
                Role       = role,
                TeamId     = teamId,
                ActionType = DataBaseCommunication.Mappers.Requests.ActionType.Insert
            };

            return(request);
        }
        public async Task <IActionResult> PostInTime(LogTimeRequest request)
        {
            IServiceProvider provider = TestServiceProvider.CreateProvider(
                services => _setup(services));

            using IServiceScope scope = provider.CreateScope();

            var result = await scope.ServiceProvider
                         .GetRequiredService <TimesheetController>()
                         .PostInTime(request);

            TimeLoggerContext dbContext = scope.ServiceProvider.GetRequiredService <TimeLoggerContext>();

            Timesheets.AddRange(dbContext.TimeSheets);
            return(result);
        }
        public LogTimeResponse LogTime(LogTimeRequest request)
        {
            var response = new LogTimeResponse {
                ResponseStatus = ResponseStatus.Success
            };

            var clientsProvider = new ClientsProvider();

            try
            {
                if (request.ActionType == ActionType.Insert)
                {
                    response.isSuccessful = clientsProvider.LogTime(request);
                    if (response.isSuccessful)
                    {
                        var refreshClientsRequest = new AllClientsRequest
                        {
                            ActionType = ActionType.Select,
                            Role       = request.Role,
                            TeamId     = request.TeamId
                        };

                        var clientsResponse = GetAllClients(refreshClientsRequest);
                        response.NewClientsList = clientsResponse.Clients;
                    }
                }
                else
                {
                    response.ResponseStatus      = ResponseStatus.Failure;
                    response.ResponseDescription = "Not update action";
                }
            }
            catch (Exception ex)
            {
                response.ResponseStatus      = ResponseStatus.Failure;
                response.ResponseDescription = ex.Message;
            }
            return(response);
        }
Example #8
0
 public void UpdateTime(int id, LogTimeRequest request)
 {
     _repository.UpdateLogTime(id, (DateTime)request.LogTime, request.Comment);
 }
Example #9
0
 public void LogTime(LogTimeRequest request)
 {
     //do stuff
 }