public TimeTrackerInfo TimeoutTimeTracker(int id)
        {
            try
            {
                var timetrack = _context.TimeTrackingLogger.Find(id);
                timetrack.TimeOut   = DateTime.Now.TimeOfDay;
                timetrack.LogStatus = (int)LogTypeEnum.TimeOut;

                _context.Update(timetrack);
                _context.SaveChanges();

                var timetrackerDetails = _mapper.Map <TimeTrackerDetails>(timetrack);
                timetrackerDetails.LogStatusName = _method.GetLogTypeName(Convert.ToInt32(timetrackerDetails.LogStatus));

                return(new TimeTrackerInfo()
                {
                    TimeTracker = timetrackerDetails, State = new StatusResponse()
                    {
                        isValid = true
                    }
                });
            }
            catch (Exception e)
            {
                return(new TimeTrackerInfo()
                {
                    State = new StatusResponse()
                    {
                        isValid = false, Message = "Time Tracker object not found."
                    }
                });
            }
        }
        public async Task <BookLogInfo> AddBookLogAsync(UserInfo model, string uri)
        {
            var clientEmail    = _query.GetClientByEmail(model.Email);
            var isClientExists = clientEmail != null;
            var book           = new BookLogInfo()
            {
            };
            var client = new ClientMaster();

            var booklog = _mapper.Map <BookLog>(model);

            booklog.Guid        = Guid.NewGuid();
            model.RefCode       = booklog.Guid.ToString();
            booklog.BookingType = Convert.ToByte(model.BookType);
            booklog.BookStatus  = model.BookStatus < 1 ? Convert.ToByte((int)BookStatusEnum.Pending) : Convert.ToByte(model.BookStatus);
            if (!model.HaveBookedBefore && !isClientExists)
            {
                client = _mapper.Map <ClientMaster>(model);
                var contacts = model.ContactNumber.ToArray();
                client.ContactNumber1 = contacts[0].ContactNumber;
                client.ContactNumber2 = contacts[1].ContactNumber;

                _context.Add(client);
                //_context.SaveChanges();

                booklog.ClientId = client.ClientId;
            }
            else
            {
                if (isClientExists)
                {
                    booklog.ClientId = clientEmail.ClientId;

                    clientEmail.ContactNumber1 = string.IsNullOrEmpty(model.ContactNumber.ElementAt(0).ContactNumber) ? client.ContactNumber1 : model.ContactNumber.ElementAt(0).ContactNumber;
                    clientEmail.ContactNumber2 = string.IsNullOrEmpty(model.ContactNumber.ElementAt(1).ContactNumber) ? client.ContactNumber2 : model.ContactNumber.ElementAt(1).ContactNumber;

                    _context.Update(clientEmail);
                    //_context.SaveChanges();
                }
                else
                {
                    return(new BookLogInfo()
                    {
                        State = new StatusResponse()
                        {
                            isValid = false,
                            Message = "Can't find client with the specified email."
                        }
                    });
                }
            }

            book = new BookLogInfo()
            {
                Client   = isClientExists ? clientEmail : client,
                BookLog  = booklog,
                BookInfo = new BookInfo()
                {
                    SpaceName      = _method.GetSpaceName(model.SpaceType),
                    FrequencyName  = _method.GetFrequencyName(model.FrequencyType),
                    BookStatusName = _method.GetBookingStatusName(model.BookStatus),
                    BookTypeName   = _method.GetBookingTypeName(model.BookType),
                    SpaceType      = model.SpaceType,
                    FrequencyType  = model.FrequencyType,
                    BookStatus     = model.BookStatus,
                    BookType       = model.BookType,
                    RoomType       = model.RoomType
                },
                State = new StatusResponse()
                {
                    isValid = true
                }
            };

            _context.Add(booklog);
            //_context.SaveChanges();

            if (model.BookType == (int)BookingTypeEnum.DevHub)
            {
                var emailParams = new EmailParametersModel()
                {
                    UserInfo = model,
                    Client   = isClientExists ? clientEmail : client,
                    Uri      = uri,
                    Id       = booklog.Id
                };
                await _email.SendEmail(_method.GetApproveEmailParameter(emailParams, false), "");

                await _email.SendEmail(_method.GetApproveEmailParameter(emailParams, true), "");
            }

            return(book);
        }