public object SubmitRegistration([FromBody] string registration) { APP_USER reg = null; //Create a new AppUser object with the information passed in. try { reg = JsonConvert.DeserializeObject <APP_USER>(registration); } catch (JsonReaderException jex) { return(BadRequest("Registration does not map to a user object. Please check JSON and resubmit." + jex.StackTrace.ToString())); } var tmp = _service.GetUser(reg.USER_NAME); //Does the email address already exist in the database? if (tmp != null) { //Someone in the database log.Error(string.Format("{0}\n\n{1}", "Username already exists.", reg.USER_SYS_ID)); return(Conflict()); } var resp = AddUser(registration); log.Info(string.Format("New registration created from new user: \n\n{0}", registration)); return(resp); }
public static bool AddAppUser(string email, string password) { bool returnValue = false; using (var db = new DbModel()) { var users = from x in db.APP_USER where x.EMAIL.Equals(email) select x; if (!users.Any()) { APP_USER newUser = new APP_USER() { EMAIL = email, PASSWORD = MyAes.EncryptStringToString(password) }; db.APP_USER.Add(newUser); db.SaveChanges(); returnValue = true; } } return(returnValue); }
void _worker_DoWork(object sender, DoWorkEventArgs e) { APP_USER user = e.Argument as APP_USER; OperationResult result = _srvUser.GetAppUser(user.USERNAME, user.PASSWORD, _bussnessParam); e.Result = result; }
public JsonResult Delete(APP_USER oModel) { try { UserBll userBll = new UserBll(); userBll.Delete(oModel.ID); var res = true; return(Json(res, JsonRequestBehavior.AllowGet)); } catch { var res = false; return(Json(res, JsonRequestBehavior.AllowGet)); } }
public JsonResult Create(APP_USER cc) { try { UserBll userBll = new UserBll(); userBll.addUser(cc); var res = true; return(Json(res, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { var res = false; return(Json(res, JsonRequestBehavior.AllowGet)); } }
public static APP_USER Add(APP_USER oModel) { try { using (UserDbEntities oContext = new UserDbEntities()) { oContext.APP_USER.Add(oModel); oContext.SaveChanges(); } } catch (Exception ex) { throw new Exception("erreur", ex); } return(oModel); }
public static List <APP_USER> Delete(int oId) { APP_USER oModel = new APP_USER(); try { using (UserDbEntities oContext = new UserDbEntities()) { oModel = oContext.APP_USER.Find(oId); oContext.APP_USER.Remove(oModel); oContext.SaveChanges(); } } catch (Exception ex) { throw new Exception("erreur", ex); } return(SelectUser()); }
public FrmMain(APP_USER user) { UserSettings.AppUser = user; InitializeComponent(); menuStripMain.Renderer = new JNRenderer(); toolsMain.Renderer = new JNRenderer(); menuStripMain.BackColor = Color.FromArgb(255, 245, 245, 245); toolsMain.BackColor = Color.FromArgb(255, 245, 245, 245); //if (MetroUI.DesignMode == false) //{ // MetroUI.Style.PropertyChanged += Style_PropertyChanged; // MetroUI.Style.DarkStyle = true; // MetroUI.Style.DarkStyle = false; //} this.Text += string.Format(" ({0})", user.USERNAME); }
public static APP_USER Update(APP_USER oModel, int ID) { try { using (UserDbEntities oContext = new UserDbEntities()) { APP_USER userInDb = new APP_USER(); userInDb = oContext.APP_USER.Find(ID); userInDb.FIRSTNAME = oModel.FIRSTNAME; userInDb.LASTNAME = oModel.LASTNAME; userInDb.BIRTHDATE = oModel.BIRTHDATE; userInDb.HEIGHT = oModel.HEIGHT; oContext.SaveChanges(); } } catch (Exception ex) { throw new Exception("erreur", ex); } return(oModel); }
public object AddUser([FromBody] JToken value) { APP_USER newUser = null; try { newUser = JsonConvert.DeserializeObject <APP_USER>(value.ToString()); string executingUser = ""; APP_USER result = _service.AddUser(newUser); log.Info(string.Format("User {0} created New user with the following data: \n\n{1}", executingUser, value)); return(Ok(result)); } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { StringBuilder errmsg = new StringBuilder(); errmsg.Append(string.Format("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State.ToString())); foreach (var ve in eve.ValidationErrors) { errmsg.Append(string.Format("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage)); } log.Error(errmsg); } return(BadRequest("netApi.Controller.AddUser(string) caused DbEntityValidationException!")); } catch (Exception e) { var msg = string.Format("Error Saving User Record.\n\nData:\n{0}.\n\n{1}", value, e.Message); log.Error(e); return(BadRequest(msg)); } }
public object UpdateUser([FromBody] JToken value) { APP_USER userToUpdate = null; try { //Deserialize the string back into an APP_USER object userToUpdate = JsonConvert.DeserializeObject <APP_USER>(value.ToString()); var executingUser = ""; var result = _service.UpdateUser(userToUpdate); log.Info(string.Format("User {0} updated UserID: {1} updated with the following data: \n\n{1}", executingUser, userToUpdate.USER_SYS_ID, userToUpdate)); return(Ok(result)); } catch (Exception e) { var msg = string.Format("Error Updating User Record.\n\nData:\n{0}.\n\n{1}", value, e.Message); log.Error(e); return(BadRequest(string.Format("Error updating user with passed in data.\n\nData:\n{0}", value))); } }
public APP_USER UpdateUser(APP_USER userToUpdate) { return(_repository.UpdateUser(userToUpdate)); }
public APP_USER AddUser(APP_USER newUser) { return(_repository.AddUser(newUser)); }
public void Update(APP_USER oModel, int ID) { UserDb.Update(oModel, ID); }
public void addUser(APP_USER oModel) { UserDb.Add(oModel); }