void ReleaseDesignerOutlets() { if (StatusDesc != null) { StatusDesc.Dispose(); StatusDesc = null; } if (StatusLanguage != null) { StatusLanguage.Dispose(); StatusLanguage = null; } if (StatusText != null) { StatusText.Dispose(); StatusText = null; } if (TextEditor != null) { TextEditor.Dispose(); TextEditor = null; } }
//POST: ADD USER public HttpResponseMessage POST(UserDetails user) { StatusDesc statusDesc = new StatusDesc(); if (user == null) { statusDesc.StatusCode = 0; statusDesc.Description = "User details cannot be null"; return(Request.CreateResponse(HttpStatusCode.OK, statusDesc)); } if (!ModelState.IsValid) { string error = ModelState.SelectMany(state => state.Value.Errors).Aggregate("", (a, b) => a + "," + b.ErrorMessage.ToString()); statusDesc.StatusCode = 0; statusDesc.Description = error; return(Request.CreateResponse(HttpStatusCode.OK, statusDesc)); } user.avatar = "https://s3.amazonaws.com/uifaces/faces/twitter/marcoramires/128.jpg"; lobjDatabase.User.Add(user); int returnvalue = lobjDatabase.SaveChanges(); statusDesc.StatusCode = returnvalue; statusDesc.Description = returnvalue == 1 ? "User added successfully" : "Unable to add user"; return(Request.CreateResponse(HttpStatusCode.OK, statusDesc)); }
//DELETE: DELETE USER public HttpResponseMessage DELETE(int Id) { StatusDesc statusDesc = new StatusDesc(); UserDetails lobjUser = lobjDatabase.User.FirstOrDefault(x => x.id == Id); lobjDatabase.User.Remove(lobjUser); int returnvalue = lobjDatabase.SaveChanges(); statusDesc.StatusCode = returnvalue; statusDesc.Description = returnvalue == 1 ? "User deleted successfully" : "Unable to delete user"; return(Request.CreateResponse(HttpStatusCode.OK, statusDesc)); }
//PUT: EDIT USER public HttpResponseMessage PUT(UserDetails user) { StatusDesc statusDesc = new StatusDesc(); UserDetails ExistingRecord = lobjDatabase.User.AsNoTracking().FirstOrDefault(x => x.id == user.id); int userId = ExistingRecord.id; ExistingRecord = user; ExistingRecord.id = userId; lobjDatabase.User.Attach(ExistingRecord); lobjDatabase.Entry(ExistingRecord).State = EntityState.Modified; int returnvalue = lobjDatabase.SaveChanges(); statusDesc.StatusCode = returnvalue; statusDesc.Description = returnvalue == 1 ? "User updated successfully" : "Unable to update user"; return(Request.CreateResponse(HttpStatusCode.OK, statusDesc)); }
public bool IsValidBankTeller(string BankCode, string Password) { bool result = IsValid(BankCode, Password); if (result == true) { StatusCode = "0"; StatusDesc = "SUCCESS"; return(true); } else { //replace the word user in the error message with the word customer2 StatusDesc = StatusDesc.Replace("USER", "TELLER"); return(false); } }