public bool AddTicket(AddTicketRequest data, int UserId) { if (data == null) { return(false); } User user = _db.Users.Where(a => a.Id == UserId).FirstOrDefault(); if (user == null) { return(false); } Ticket ticket = new Ticket(); ticket.ContactId = 1; ticket.Query = data.Query; ticket.Status = "Raised"; ticket.UserId = UserId; _db.Tickets.Add(ticket); _db.SaveChanges(); return(true); }
public bool AddAdmin(AddUserRequest data) { if (data == null) { return(false); } if (data.Password == "") { return(false); } Admin admin = this.GetAdmins().Where(a => data.Username == a.Username).FirstOrDefault(); if (admin != null) { return(false); } admin = new Admin(); admin.Username = data.Username; admin.Password = data.Password; _db.Admins.Add(admin); _db.SaveChanges(); return(true); }