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 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)); } }