public string Post([FromBody] Users value) { if (!dbContext.Users.Any(user => user.Login.Equals(value.Login))) { Users user = new Users(); user.Id = value.Id; user.Firstname = value.Firstname; user.Lastname = value.Lastname; user.Role = value.Role; user.Phone = value.Phone; user.Email = value.Email; user.Login = value.Login; user.Password = value.Password; try { dbContext.Add(user); dbContext.SaveChanges(); return(JsonConvert.SerializeObject("User created")); } catch (Exception e) { return(JsonConvert.SerializeObject(e.InnerException.Message)); } } else { return(JsonConvert.SerializeObject("User already exists")); } }
public string Post([FromBody] Managers value) { Managers manager = new Managers(); manager.Id = value.Id; manager.UserId = value.UserId; manager.HotelId = value.HotelId; try { dbContext.Add(manager); dbContext.SaveChanges(); return(JsonConvert.SerializeObject("Manager added")); } catch (Exception e) { return(JsonConvert.SerializeObject(e.InnerException.Message)); } }