public ApiGridResponse EditDataUser(TOURIS_TV_USER userView) { ApiGridResponse res = new ApiGridResponse(); ResultStatus rs = new ResultStatus(); try { using (TourismpediaEntities tourisdb = new TourismpediaEntities()) { TOURIS_TM_USER user = tourisdb.TOURIS_TM_USER.Find(userView.ID); user.USER_NAME = userView.USER_NAME; user.USER_MAIL = userView.USER_MAIL; user.LAST_MODIFIED_BY = userView.LAST_MODIFIED_BY; user.LAST_MODIFIED_TIME = userView.LAST_MODIFIED_TIME; tourisdb.Entry(user).State = EntityState.Modified; tourisdb.SaveChanges(); rs.SetSuccessStatus(); } res = ResGetDataTable(new object[] { rs }, null); } catch (Exception ex) { res = ResGetDataTable(null, ex); } return(res); }
public ApiGridResponse InsertDataUser(TOURIS_TV_USER userView) { ApiGridResponse res = new ApiGridResponse(); ResultStatus rs = new ResultStatus(); try { TOURIS_TM_USER user = new TOURIS_TM_USER(); using (TourismpediaEntities tourisdb = new TourismpediaEntities()) { user.USER_NAME = userView.USER_NAME; user.USER_MAIL = userView.USER_MAIL; user.CREATED_BY = userView.CREATED_BY; user.CREATED_TIME = userView.CREATED_TIME; tourisdb.TOURIS_TM_USER.Add(user); tourisdb.SaveChanges(); rs.SetSuccessStatus(); } res = ResGetDataTable(new object[] { rs }, null); } catch (Exception ex) { res = ResGetDataTable(null, ex); } return(res); }
public ApiGridResponse RetrieveDataUser() { ApiGridResponse res = new ApiGridResponse(); try { List <TOURIS_TM_USER> users = new List <TOURIS_TM_USER>(); List <TOURIS_TV_USER> userViews = new List <TOURIS_TV_USER>(); using (TourismpediaEntities tourisdb = new TourismpediaEntities()) { users = tourisdb.TOURIS_TM_USER.ToList(); } if (users.Count > 0) { foreach (var item in users) { TOURIS_TV_USER userView = new TOURIS_TV_USER(); userView.USER_NAME = item.USER_NAME; userView.USER_MAIL = item.USER_MAIL; userViews.Add(userView); } } res = ResGetDataTable(new object[] { userViews }, null); } catch (Exception ex) { res = ResGetDataTable(null, ex); } return(res); }
public ActionResult ActionDelete(TOURIS_TV_USER userView) { TOURIS_TV_USER userRes = new TOURIS_TV_USER(); userRes = JsonConvert.DeserializeObject <TOURIS_TV_USER>(ParsingObject.JsonData(userView, "User", "DeleteObjUser")); return(View(userRes)); }
public ActionResult Detail(int id) { TOURIS_TV_USER userView = new TOURIS_TV_USER(); TOURIS_TV_USER userRes = new TOURIS_TV_USER(); userView.ID = id; userRes = JsonConvert.DeserializeObject <TOURIS_TV_USER>(ParsingObject.RequestData(id, "User", "RetrieveData", EnumList.IHttpMethod.Put.ToString())); return(View(userRes)); }
public ActionResult ActionEdit(TOURIS_TV_USER userView, HttpPostedFileBase postedFile) { try { string physicalPath = ""; TOURIS_TV_USER_PROFILE userProfileView = new TOURIS_TV_USER_PROFILE(); if (postedFile != null) { string ImageName = System.IO.Path.GetFileName(postedFile.FileName); //file2 to store path and url physicalPath = Server.MapPath("~" + Common.GetPathFolderImg() + ImageName); userView.PHOTO_PATH = Common.GetPathFolderImg() + ImageName; userProfileView.PHOTO_PATH = userView.PHOTO_PATH; } userView.LAST_MODIFIED_BY = CurrentUser.GetCurrentUserId(); userView.LAST_MODIFIED_TIME = CurrentUser.GetCurrentDateTime(); userProfileView.GENDER = userView.GENDER; userProfileView.BORN = userView.BORN; userProfileView.ADDRESS = userView.ADDRESS; userProfileView.DESCRIPTION = userView.DESCRIPTION; userProfileView.JOB = userView.JOB; userProfileView.COMPANY = userView.COMPANY; userProfileView.HOBBY = userView.HOBBY; userView.TOURIS_TV_USER_PROFILE.Add(userProfileView); rs = JsonConvert.DeserializeObject <ResultStatus>(ParsingObject.RequestData(userView, "User", "Edit", EnumList.IHttpMethod.Post.ToString())); if (rs.IsSuccess) { if (physicalPath != "") { postedFile.SaveAs(physicalPath); } rs.SetSuccessStatus("Data has been edited successfully"); TempData["msgSuccess"] = rs.MessageText; } else { rs.SetErrorStatus("Data failed to edited"); TempData["msgError"] = rs.MessageText; } } catch (Exception ex) { ModelState.AddModelError("", ex.Message); rs.SetErrorStatus("Data failed to edited"); TempData["msgError"] = rs.MessageText; } return(RedirectToAction("Index")); }
public ActionResult ActionLogin(CUSTOM_LOGIN login) { TOURIS_TV_USER userView = new TOURIS_TV_USER(); TOURIS_TV_USER userRes = new TOURIS_TV_USER(); userRes = JsonConvert.DeserializeObject <TOURIS_TV_USER>(ParsingObject.RequestData(login, "User", "Login", EnumList.IHttpMethod.Post.ToString())); if (userRes.ID > 0) { Session["USER_ID_ID"] = userRes.ID; Session["USER_ID"] = userRes.USER_ID; Session["USER_EMAIL"] = userRes.USER_MAIL; Session["IS_SUPER_ADMIN"] = userRes.IS_SUPER_ADMIN; Session["USER_NAME"] = userRes.USER_NAME; } else { TempData["msgError"] = "Data incorrent"; return(RedirectToAction("Login")); } return(RedirectToAction("Index", "Home")); }
public ApiGridResponse DeleteDataUser(TOURIS_TV_USER userView) { ApiGridResponse res = new ApiGridResponse(); ResultStatus rs = new ResultStatus(); try { using (TourismpediaEntities tourisdb = new TourismpediaEntities()) { TOURIS_TM_USER user = tourisdb.TOURIS_TM_USER.Find(userView.ID); tourisdb.TOURIS_TM_USER.Remove(user); tourisdb.SaveChanges(); rs.SetSuccessStatus(); } res = ResGetDataTable(new object[] { rs }, null); } catch (Exception ex) { res = ResGetDataTable(null, ex); } return(res); }
public JObject DeleteObjUser(string param) { TOURIS_TV_USER user = JsonConvert.DeserializeObject<TOURIS_TV_USER>(param); return JObject.FromObject(userF.DeleteDataUser(user)); }
public IHttpActionResult Login(CUSTOM_LOGIN login) { ApiResData res = new ApiResData(); try { if (!ModelState.IsValid) { rs.SetErrorStatus(eFunc.fg.SFailed); resObj = JObject.FromObject(res.ResCUD(new object[] { rs }, eFunc.fg.DataNf, new Exception(eFunc.fg.DataIsntValid))); return(Content(HttpStatusCode.NotFound, resObj)); } TOURIS_TM_USER user = repo.Login(login.Email, login.Password); TOURIS_TV_USER userView = new TOURIS_TV_USER(); if (user != null) { userView.ID = user.ID; userView.USER_ID = user.USER_ID; userView.USER_MAIL = user.USER_MAIL; userView.USER_NAME = user.USER_NAME; userView.IS_SUPER_ADMIN = user.IS_SUPER_ADMIN; userView.LAST_LOGIN = user.LAST_LOGIN; userView.PASSWORD = user.PASSWORD; userView.PHOTO_PATH = user.TOURIS_TM_USER_PROFILE.FirstOrDefault().PHOTO_PATH; userView.GENDER = user.TOURIS_TM_USER_PROFILE.FirstOrDefault().GENDER; userView.BORN = user.TOURIS_TM_USER_PROFILE.FirstOrDefault().BORN; userView.ADDRESS = user.TOURIS_TM_USER_PROFILE.FirstOrDefault().ADDRESS; userView.DESCRIPTION = user.TOURIS_TM_USER_PROFILE.FirstOrDefault().DESCRIPTION; userView.JOB = user.TOURIS_TM_USER_PROFILE.FirstOrDefault().JOB; userView.COMPANY = user.TOURIS_TM_USER_PROFILE.FirstOrDefault().COMPANY; userView.HOBBY = user.TOURIS_TM_USER_PROFILE.FirstOrDefault().HOBBY; userView.CREATED_BY = user.CREATED_BY; userView.CREATED_TIME = user.CREATED_TIME; userView.LAST_MODIFIED_BY = user.LAST_MODIFIED_BY; userView.LAST_MODIFIED_TIME = user.LAST_MODIFIED_TIME; if (user.TOURIS_TM_USER_PROFILE != null) { TOURIS_TV_USER_PROFILE userProfileView = new TOURIS_TV_USER_PROFILE(); userProfileView.ID = user.ID; userProfileView.USER_ID_ID = user.TOURIS_TM_USER_PROFILE.FirstOrDefault().USER_ID_ID; userProfileView.PHOTO_PATH = user.TOURIS_TM_USER_PROFILE.FirstOrDefault().PHOTO_PATH; userProfileView.GENDER = user.TOURIS_TM_USER_PROFILE.FirstOrDefault().GENDER; userProfileView.BORN = user.TOURIS_TM_USER_PROFILE.FirstOrDefault().BORN; userProfileView.ADDRESS = user.TOURIS_TM_USER_PROFILE.FirstOrDefault().ADDRESS; userProfileView.DESCRIPTION = user.TOURIS_TM_USER_PROFILE.FirstOrDefault().DESCRIPTION; userProfileView.JOB = user.TOURIS_TM_USER_PROFILE.FirstOrDefault().JOB; userProfileView.COMPANY = user.TOURIS_TM_USER_PROFILE.FirstOrDefault().COMPANY; userProfileView.HOBBY = user.TOURIS_TM_USER_PROFILE.FirstOrDefault().HOBBY; userProfileView.CREATED_BY = user.TOURIS_TM_USER_PROFILE.FirstOrDefault().CREATED_BY; userProfileView.CREATED_TIME = user.TOURIS_TM_USER_PROFILE.FirstOrDefault().CREATED_TIME; userProfileView.LAST_MODIFIED_BY = user.TOURIS_TM_USER_PROFILE.FirstOrDefault().LAST_MODIFIED_BY; userProfileView.LAST_MODIFIED_TIME = user.TOURIS_TM_USER_PROFILE.FirstOrDefault().LAST_MODIFIED_TIME; if (user.TOURIS_TM_USER_PROFILE.FirstOrDefault().TOURIS_TM_USER_PROFILE_SOSMED.Count > 0) { foreach (var itemSosmed in user.TOURIS_TM_USER_PROFILE.FirstOrDefault().TOURIS_TM_USER_PROFILE_SOSMED) { TOURIS_TV_USER_PROFILE_SOSMED userProfileSosmedView = new TOURIS_TV_USER_PROFILE_SOSMED(); userProfileSosmedView.ID = user.ID; userProfileSosmedView.USER_PROFILE_ID = itemSosmed.USER_PROFILE_ID; userProfileSosmedView.SOSMED_NAME = itemSosmed.SOSMED_NAME; userProfileSosmedView.SOSMED_PATH = itemSosmed.SOSMED_PATH; userProfileSosmedView.CREATED_BY = itemSosmed.CREATED_BY; userProfileSosmedView.CREATED_TIME = itemSosmed.CREATED_TIME; userProfileSosmedView.LAST_MODIFIED_BY = itemSosmed.LAST_MODIFIED_BY; userProfileSosmedView.LAST_MODIFIED_TIME = itemSosmed.LAST_MODIFIED_TIME; userProfileView.TOURIS_TV_USER_PROFILE_SOSMED.Add(userProfileSosmedView); } } userView.TOURIS_TV_USER_PROFILE.Add(userProfileView); } rs.SetSuccessStatus(); } resObj = JObject.FromObject(res.ResGetDataTable(new object[] { userView }, null)); return(Content(HttpStatusCode.OK, resObj)); } catch (Exception ex) { rs.SetErrorStatus(ex.Message); resObj = JObject.FromObject(res.ResGetDataTable(new object[] { rs }, new Exception(eFunc.fg.DataNf))); return(Content(HttpStatusCode.BadRequest, resObj)); } }
public IHttpActionResult GridBind() { ApiResData res = new ApiResData(); try { List <TOURIS_TM_USER> users = repo.GridBind(); List <TOURIS_TV_USER> userViews = new List <TOURIS_TV_USER>(); if (users.Count > 0) { foreach (var item in users) { TOURIS_TV_USER userView = new TOURIS_TV_USER(); userView.ID = item.ID; userView.USER_ID = item.USER_ID; userView.USER_MAIL = item.USER_MAIL; userView.USER_NAME = item.USER_NAME; userView.IS_SUPER_ADMIN = item.IS_SUPER_ADMIN; userView.LAST_LOGIN = item.LAST_LOGIN; userView.PASSWORD = item.PASSWORD; userView.CREATED_BY = item.CREATED_BY; userView.CREATED_TIME = item.CREATED_TIME; userView.LAST_MODIFIED_BY = item.LAST_MODIFIED_BY; userView.LAST_MODIFIED_TIME = item.LAST_MODIFIED_TIME; if (item.TOURIS_TM_USER_PROFILE.Count > 0) { TOURIS_TV_USER_PROFILE userProfileView = new TOURIS_TV_USER_PROFILE(); userProfileView.ID = item.ID; userProfileView.USER_ID_ID = item.TOURIS_TM_USER_PROFILE.FirstOrDefault().USER_ID_ID; userProfileView.PHOTO_PATH = item.TOURIS_TM_USER_PROFILE.FirstOrDefault().PHOTO_PATH; userProfileView.GENDER = item.TOURIS_TM_USER_PROFILE.FirstOrDefault().GENDER; userProfileView.BORN = item.TOURIS_TM_USER_PROFILE.FirstOrDefault().BORN; userProfileView.ADDRESS = item.TOURIS_TM_USER_PROFILE.FirstOrDefault().ADDRESS; userProfileView.DESCRIPTION = item.TOURIS_TM_USER_PROFILE.FirstOrDefault().DESCRIPTION; userProfileView.JOB = item.TOURIS_TM_USER_PROFILE.FirstOrDefault().JOB; userProfileView.COMPANY = item.TOURIS_TM_USER_PROFILE.FirstOrDefault().COMPANY; userProfileView.HOBBY = item.TOURIS_TM_USER_PROFILE.FirstOrDefault().HOBBY; userProfileView.CREATED_BY = item.TOURIS_TM_USER_PROFILE.FirstOrDefault().CREATED_BY; userProfileView.CREATED_TIME = item.TOURIS_TM_USER_PROFILE.FirstOrDefault().CREATED_TIME; userProfileView.LAST_MODIFIED_BY = item.TOURIS_TM_USER_PROFILE.FirstOrDefault().LAST_MODIFIED_BY; userProfileView.LAST_MODIFIED_TIME = item.TOURIS_TM_USER_PROFILE.FirstOrDefault().LAST_MODIFIED_TIME; if (item.TOURIS_TM_USER_PROFILE.FirstOrDefault().TOURIS_TM_USER_PROFILE_SOSMED.Count > 0) { foreach (var itemSosmed in item.TOURIS_TM_USER_PROFILE.FirstOrDefault().TOURIS_TM_USER_PROFILE_SOSMED) { TOURIS_TV_USER_PROFILE_SOSMED userProfileSosmedView = new TOURIS_TV_USER_PROFILE_SOSMED(); userProfileSosmedView.ID = item.ID; userProfileSosmedView.USER_PROFILE_ID = itemSosmed.USER_PROFILE_ID; userProfileSosmedView.SOSMED_NAME = itemSosmed.SOSMED_NAME; userProfileSosmedView.SOSMED_PATH = itemSosmed.SOSMED_PATH; userProfileSosmedView.CREATED_BY = itemSosmed.CREATED_BY; userProfileSosmedView.CREATED_TIME = itemSosmed.CREATED_TIME; userProfileSosmedView.LAST_MODIFIED_BY = itemSosmed.LAST_MODIFIED_BY; userProfileSosmedView.LAST_MODIFIED_TIME = itemSosmed.LAST_MODIFIED_TIME; userProfileView.TOURIS_TV_USER_PROFILE_SOSMED.Add(userProfileSosmedView); } } userView.TOURIS_TV_USER_PROFILE.Add(userProfileView); } userViews.Add(userView); } rs.SetSuccessStatus(); } resObj = JObject.FromObject(res.ResGetDataTable(new object[] { userViews }, null)); return(Content(HttpStatusCode.OK, resObj)); } catch (Exception ex) { rs.SetErrorStatus(ex.Message); resObj = JObject.FromObject(res.ResGetDataTable(new object[] { rs }, new Exception(eFunc.fg.DataNf))); return(Content(HttpStatusCode.BadRequest, resObj)); } }
public IHttpActionResult Edit(TOURIS_TV_USER userView) { ApiResData res = new ApiResData(); TOURIS_TM_USER user = new TOURIS_TM_USER(); TOURIS_TM_USER_PROFILE userProfile = new TOURIS_TM_USER_PROFILE(); List <TOURIS_TM_USER_PROFILE_SOSMED> userProfileSosmeds = new List <TOURIS_TM_USER_PROFILE_SOSMED>(); try { //if (!ModelState.IsValid) //{ // rs.SetErrorStatus(eFunc.fg.SFailed); // resObj = JObject.FromObject(res.ResCUD(new object[] { rs }, eFunc.fg.Edit, new Exception(eFunc.fg.DataIsntValid))); // return Content(HttpStatusCode.NotFound, resObj); //} if (userView != null) { user.ID = userView.ID; user.USER_ID = userView.USER_ID; user.USER_MAIL = userView.USER_MAIL; user.USER_NAME = userView.USER_NAME; user.IS_SUPER_ADMIN = userView.IS_SUPER_ADMIN; user.LAST_MODIFIED_BY = userView.LAST_MODIFIED_BY; user.LAST_MODIFIED_TIME = userView.LAST_MODIFIED_TIME; if (userView.TOURIS_TV_USER_PROFILE != null) { userProfile.USER_ID_ID = userView.ID; if (userView.TOURIS_TV_USER_PROFILE.FirstOrDefault().PHOTO_PATH != null) { userProfile.PHOTO_PATH = userView.TOURIS_TV_USER_PROFILE.FirstOrDefault().PHOTO_PATH; } userProfile.GENDER = userView.TOURIS_TV_USER_PROFILE.FirstOrDefault().GENDER; userProfile.BORN = userView.TOURIS_TV_USER_PROFILE.FirstOrDefault().BORN; userProfile.ADDRESS = userView.TOURIS_TV_USER_PROFILE.FirstOrDefault().ADDRESS; userProfile.DESCRIPTION = userView.TOURIS_TV_USER_PROFILE.FirstOrDefault().DESCRIPTION; userProfile.JOB = userView.TOURIS_TV_USER_PROFILE.FirstOrDefault().JOB; userProfile.COMPANY = userView.TOURIS_TV_USER_PROFILE.FirstOrDefault().COMPANY; userProfile.HOBBY = userView.TOURIS_TV_USER_PROFILE.FirstOrDefault().HOBBY; userProfile.LAST_MODIFIED_BY = userView.LAST_MODIFIED_BY; userProfile.LAST_MODIFIED_TIME = userView.LAST_MODIFIED_TIME; if (userView.TOURIS_TV_USER_PROFILE.FirstOrDefault().TOURIS_TV_USER_PROFILE_SOSMED.Count > 0) { foreach (var itemSosmed in userView.TOURIS_TV_USER_PROFILE.FirstOrDefault().TOURIS_TV_USER_PROFILE_SOSMED) { TOURIS_TM_USER_PROFILE_SOSMED userProfileSosmed = new TOURIS_TM_USER_PROFILE_SOSMED(); userProfileSosmed.ID = user.ID; userProfileSosmed.USER_PROFILE_ID = itemSosmed.USER_PROFILE_ID; userProfileSosmed.SOSMED_NAME = itemSosmed.SOSMED_NAME; userProfileSosmed.SOSMED_PATH = itemSosmed.SOSMED_PATH; userProfileSosmed.CREATED_BY = itemSosmed.CREATED_BY; userProfileSosmed.CREATED_TIME = itemSosmed.CREATED_TIME; userProfileSosmed.LAST_MODIFIED_BY = itemSosmed.LAST_MODIFIED_BY; userProfileSosmed.LAST_MODIFIED_TIME = itemSosmed.LAST_MODIFIED_TIME; userProfileSosmeds.Add(userProfileSosmed); } } } } rs = repo.Edit(user, userProfile, userProfileSosmeds); if (rs.IsSuccess) { rs.SetSuccessStatus(); } else { rs.SetErrorStatus(eFunc.fg.SFailed); } resObj = JObject.FromObject(res.ResCUD(new object[] { rs }, eFunc.fg.Edit, null)); return(Content(HttpStatusCode.OK, resObj)); } catch (Exception ex) { rs.SetErrorStatus(ex.Message); resObj = JObject.FromObject(res.ResCUD(new object[] { rs }, eFunc.fg.Edit, new Exception(eFunc.fg.EFailed))); return(Content(HttpStatusCode.BadRequest, resObj)); } }