public bool CreateAccount(AddRegisterRequest request)
        {
            List <Register> values;

            values = _db.Registers.Where(a => a.Email == request.email).ToList();
            if (values.Count > 0)
            {
                return(false);
            }
            else
            {
                Register register = new Register
                {
                    FirstName    = request.firstname,
                    LastName     = request.lastname,
                    Email        = request.email,
                    Password     = EncodePasswordToBase64(request.password),
                    Created      = DateTime.Now,
                    LastModified = DateTime.Now
                };
                _db.Registers.Add(register);
                _db.SaveChanges();
                return(true);
            }
        }
 public bool AddContact(AddContactRequest request)
 {
     if (request != null)
     {
         int secretNumber = 5306;
         request.userId = request.userId - secretNumber;
         var result = _db.Contacts.Where(a => a.registerId == request.userId).FirstOrDefault();
         if (result == null)
         {
             Contact contact = new Contact
             {
                 Email      = request.email,
                 Mobile     = request.mobile,
                 registerId = request.userId
             };
             _db.Contacts.Add(contact);
             _db.SaveChanges();
             return(true);
         }
     }
     return(false);
 }
        public bool AddTicket(AddTicketRequest request)
        {
            int secretKey = 5306;

            request.UserId = request.UserId - secretKey;
            if (request != null)
            {
                var result = _db.Tickets.Where(a => a.Title == request.title && a.registerId == request.UserId).FirstOrDefault();
                if (result != null)
                {
                    return(false);
                }
                else
                {
                    Ticket ticket = new Ticket
                    {
                        Title        = request.title,
                        Description  = request.description,
                        Status       = "open",
                        Priority     = 2,
                        ResponderId  = 0,
                        Created      = DateTime.Now,
                        LastModified = DateTime.Now,
                        registerId   = request.UserId
                    };
                    _db.Tickets.Add(ticket);
                    _db.SaveChanges();



                    var result1 = _db.Tickets.Where(a => a.registerId == request.UserId && a.Title == request.title && a.Description == request.description).FirstOrDefault();
                    //Adding all information to logs table

                    Logs logs = new Logs
                    {
                        Description  = request.description,
                        Title        = request.title,
                        LastModified = DateTime.Now,
                        ticketId     = result1.Id,
                        registerId   = request.UserId
                    };
                    _db.Logs.Add(logs);
                    _db.SaveChanges();
                    return(true);
                }
            }
            return(false);
        }