public IHttpActionResult Post([FromBody] PersonalZone value) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } PersonalZone pz = value; if (pz == null) { return(BadRequest("Cannot go to menu, please try again")); } Globals.ListToItemArray(Globals.pList); EntitiesManager.getInstance().UpdateUsersZone(value); return(CreatedAtRoute("DefaultApi", new { id = pz.userId }, pz)); }
public User UpdateUsersZone(PersonalZone details) { User ret = GetUser(details.userId); using (var session = NHibernateManager.OpenSession()) { using (var transaction = session.BeginTransaction()) { ret.Allergies = ConvertOptionNameToId(details.userAllergies, Globals.allergyArray); ret.Preferences = ConvertOptionNameToId(details.userPreferences, Globals.preferenceArray); try { session.Update(ret); transaction.Commit(); } catch (Exception e) { transaction.Rollback(); } } } return(ret); }