public string[] GetCommunityCoInfo(long userId) { string[] list = new string[2]; string communityName = "No community"; string communityApart = "No apartment"; user selfUser = entities.users.Find(userId); if (selfUser.create_userid != null) { long coadminUserId = (long)selfUser.create_userid; communuser communuserResult = entities.communusers.Where(m => m.user_id == coadminUserId).FirstOrDefault(); if (communuserResult != null) { long communityID = communuserResult.commun_id; community community = entities.communities.Find(communityID); communityName = community.first_name; communityApart = community.apart; } list[0] = communityName; list[1] = communityApart; return(list); } else { return(list); } }
// GET: webmaster/pagos public ActionResult recibidos(string searchString = "") { if (Session["USER_ID"] != null) { long userId = (long)Session["USER_ID"]; user curUser = entities.users.Find(userId); List <PlanViewModel> paymentList = new List <PlanViewModel>(); List <package> packageList = entities.packages.ToList(); foreach (var item in packageList) { List <community> communityList = entities.communities.Where(m => m.package_id == item.id).ToList(); foreach (var com in communityList) { communuser communuser = entities.communusers.Where(m => m.commun_id == com.id).FirstOrDefault(); if (communuser != null) { user adminUser = entities.users.Find(communuser.user_id); PlanViewModel vm = new PlanViewModel(); vm.packageName = item.first_name; vm.adminEmail = adminUser.email; vm.adminName = adminUser.first_name1 + " " + adminUser.last_name1; List <payment> payList = entities.payments.Where(m => m.to_user_id == adminUser.id).ToList(); decimal p = 0; foreach (var payItem in payList) { if (payItem.quantity != null) { p += (decimal)payItem.quantity; } } vm.payment = p; paymentList.Add(vm); } } } List <ShowMessage> pubMessageList = ep.GetChatMessages(userId); List <contactinfo> contactinfoList = entities.contactinfoes.Where(m => m.user_id == userId).ToList(); List <document_type> document_category_list = entities.document_type.ToList(); recibidosPagosViewModel viewModel = new recibidosPagosViewModel(); viewModel.side_menu = "pagos"; viewModel.side_sub_menu = "recibidos"; viewModel.curUser = curUser; viewModel.document_category_list = document_category_list; viewModel.pubTaskList = ep.GetNotifiTaskList(userId); viewModel.pubMessageList = pubMessageList; viewModel.messageCount = ep.GetUnreadMessageCount(pubMessageList); viewModel.paymentList = paymentList; viewModel.searchString = searchString; return(View(viewModel)); } else { return(Redirect(ep.GetLogoutUrl())); } }
// GET: webmaster/administradores public ActionResult listado(string searchStr = "") { if (Session["USER_ID"] != null) { long userId = (long)Session["USER_ID"]; user curUser = entities.users.Find(userId); List <ShowMessage> pubMessageList = ep.GetChatMessages(userId); List <user> coadminList = new List <user>(); Dictionary <long, string> communityDict = new Dictionary <long, string>(); if (searchStr == "") { var query = (from r in entities.users where r.role == 3 select r); coadminList = query.ToList(); } else { var query = (from r in entities.users where r.role == 3 && (r.first_name1.Contains(searchStr) || r.last_name1.Contains(searchStr)) select r); coadminList = query.ToList(); } foreach (var item in coadminList) { communuser communuser = entities.communusers.Where(m => m.user_id == item.id).FirstOrDefault(); if (communuser != null) { community community = entities.communities.Find(communuser.commun_id); communityDict.Add(item.id, community.first_name); } else { communityDict.Add(item.id, "No community"); } } listadoAdminViewModel viewModel = new listadoAdminViewModel(); viewModel.side_menu = "webmaster"; viewModel.side_sub_menu = "webmaster_listado"; viewModel.curUser = curUser; viewModel.coadminList = coadminList; viewModel.communityDict = communityDict; viewModel.pubTaskList = ep.GetNotifiTaskList(userId); viewModel.pubMessageList = pubMessageList; viewModel.messageCount = ep.GetUnreadMessageCount(pubMessageList); return(View(viewModel)); } else { return(Redirect(ep.GetLogoutUrl())); } }
public ActionResult panel(long?id) { if (Session["USER_ID"] != null) { if (id != null) { try { long userId = (long)Session["USER_ID"]; long comId = Convert.ToInt64(id); long communityAct = Convert.ToInt64(Session["CURRENT_COMU"]); List <blog> blogList = new List <blog>(); user curUser = entities.users.Find(userId); List <ShowMessage> pubMessageList = ep.GetChatMessages(userId); communuser communuser = entities.communusers.Where(m => m.commun_id == comId).FirstOrDefault(); if (communuser != null) { long comUserId = communuser.user_id; blogList = entities.blogs.Where(m => m.user_id == comUserId).ToList(); } controlViewModel viewModel = new controlViewModel(); viewModel.ComID = comId; viewModel.communityID1 = Convert.ToInt64(Session["CURRENT_COMU"]); viewModel.side_menu = "control"; viewModel.document_category_list = entities.document_type.Where(x => x.community_id == communityAct).ToList(); viewModel.curUser = curUser; viewModel.pubTaskList = ep.GetNotifiTaskList(userId); viewModel.pubMessageList = pubMessageList; viewModel.messageCount = ep.GetUnreadMessageCount(pubMessageList); viewModel.blogList = blogList; return(View(viewModel)); } catch (Exception ex) { return(Redirect(Url.Action("Index", "Error"))); } } else { return(Redirect(Url.Action("NotFound", "Error"))); } } else { return(Redirect(ep.GetLogoutUrl())); } }
// GET: webmaster/administradores public ActionResult listado(string Error) { if (Session["USER_ID"] != null) { long userId = (long)Session["USER_ID"]; long communityAct = Convert.ToInt64(Session["CURRENT_COMU"]); user curUser = entities.users.Find(userId); List <ShowMessage> pubMessageList = ep.GetChatMessages(userId); List <user> coadminList = new List <user>(); Dictionary <long, string> communityDict = new Dictionary <long, string>(); var query = (from r in entities.users where (r.role == 2 || r.role == 4) && r.is_del != true select r); coadminList = query.ToList(); foreach (var item in coadminList) { communuser communuser = entities.communusers.Where(m => m.user_id == item.id).FirstOrDefault(); if (communuser != null) { community community = entities.communities.Find(communuser.commun_id); communityDict.Add(item.id, community.first_name); } else { communityDict.Add(item.id, "Sin comunidades"); } } listadoAdminViewModel viewModel = new listadoAdminViewModel(); viewModel.side_menu = "administradores"; viewModel.side_sub_menu = "administradores_listado"; viewModel.curUser = curUser; viewModel.coadminList = coadminList; viewModel.communityDict = communityDict; viewModel.pubTaskList = ep.GetNotifiTaskList(userId); viewModel.pubMessageList = pubMessageList; viewModel.messageCount = ep.GetUnreadMessageCount(pubMessageList); ViewBag.msgError = Error; return(View(viewModel)); } else { return(Redirect(ep.GetLogoutUrl())); } }
public string[] GetCommunityInfo(long userId) { string[] list = new string[3]; string communityName = "No community"; string communityApart = "No apartment"; string cID = "No ID"; communuser communuserResult = entities.communusers.Where(m => m.user_id == userId).FirstOrDefault(); if (communuserResult != null) { long communityID = communuserResult.commun_id; community community = entities.communities.Find(communityID); communityName = community.first_name; communityApart = community.apart; cID = Convert.ToString(communityID); } list[0] = communityName; list[1] = communityApart; list[2] = cID; return(list); }
public async Task <ActionResult> SubmitRegister(string Name, string LastName, string LastNameMaterno, string CommunityName, string Address, string PhoneNumber, string Email, string Password, string ConfirmPassword, long PackageId) { Session["Reg_Name"] = Name; Session["Reg_LastName"] = LastName; Session["Reg_LastNameMaterno"] = LastNameMaterno; Session["Reg_CommunityName"] = CommunityName; Session["Reg_Address"] = Address; Session["Reg_PhoneNumber"] = PhoneNumber; Session["Reg_Email"] = Email; Session["Reg_Password"] = Password; Session["Reg_ConfirmPassword"] = ConfirmPassword; if (Password != ConfirmPassword) { Session["Register_Result"] = "Confirm password have to matach with password"; } else { try { suscribe suscribe = entities.suscribes.Where(m => m.email.Equals(Email) && m.package_id == PackageId).FirstOrDefault(); if (suscribe != null) { Session["Register_Result"] = "User already exist for same email"; } else { // Check PackageId is valid package package = entities.packages.Where(m => m.id == PackageId).FirstOrDefault(); if (package != null) { // Insert new suscribe coadmin user user1 = new user(); user1.first_name1 = Name; user1.last_name1 = LastName; user1.mother_last_name1 = LastNameMaterno; user1.first_name2 = CommunityName; user1.postal_address = Address; user1.phone_number1 = PhoneNumber; user1.email = Email; user1.password = ep.Encrypt(Password); user1.is_admin = false; user1.is_logged = false; user1.is_active = false; user1.role = 2; user1.acq_date = DateTime.Now; user1.package_id = PackageId; user1.is_paid = false; entities.users.Add(user1); entities.SaveChanges(); // create new community for current coadmin community community = new community(); community.admin_email = Email; community.package_id = PackageId; community.description = ""; community.first_name = CommunityName; community.created_at = DateTime.Now; community.updated_at = DateTime.Now; community.is_active = true; community.apart = ""; entities.communities.Add(community); entities.SaveChanges(); // Create communuser communuser communuser = new communuser(); communuser.commun_id = community.id; communuser.user_id = user1.id; entities.communusers.Add(communuser); entities.SaveChanges(); Session["USER_ID"] = user1.id; Session["USER_ROLE"] = 2; Session["Active"] = false; Session["PACK_ID"] = PackageId; Session["Register_Result"] = "success"; string patialView = "~/Views/iniciar/emailing.cshtml"; emailingViewModel viewModel = new emailingViewModel(); viewModel.firstName = CommunityName; viewModel.lastName = LastName; viewModel.fromEmail = "*****@*****.**"; viewModel.toEmail = Email; string emailTemplate = ViewRenderer.RenderPartialView(patialView, viewModel); int a = await ep.SendAlertEmail("", Email, CommunityName + " " + LastName, "añadir título", "has sido añadido como titular\n password: "******"Register_Result"] = "PackageId is invalid"; } } } catch (Exception ex) { Session["Register_Result"] = ex.Message; } } return(Redirect(Url.Action("Register", "suscribe", new { packageId = PackageId }))); }
public ActionResult editadmin(long adminID, HttpPostedFileBase user_logo, string first_name1, string last_name1, string mother_last_name1, string email, string password, List <string> communityID) { try { user editAdmin = entities.users.Find(adminID); editAdmin.first_name1 = first_name1; editAdmin.last_name1 = last_name1; editAdmin.mother_last_name1 = mother_last_name1; editAdmin.email = email; editAdmin.password = ep.Encrypt(password); if (user_logo != null && user_logo.ContentLength > 0) { var fileName = Path.GetFileName(user_logo.FileName); if (!Directory.Exists(Path.Combine(Server.MapPath("~/"), "Upload"))) { Directory.CreateDirectory(Path.Combine(Server.MapPath("~/"), "Upload")); } if (!Directory.Exists(Path.Combine(Server.MapPath("~/Upload/"), "User_Logo"))) { Directory.CreateDirectory(Path.Combine(Server.MapPath("~/Upload/"), "User_Logo")); } // store the file inside ~/App_Data/uploads folder var path = Path.Combine(Server.MapPath("~/Upload/User_Logo"), fileName); user_logo.SaveAs(path); editAdmin.user_img = fileName; } entities.SaveChanges(); if (communityID != null) { List <communuser> comxuserAnterior = entities.communusers.Where(x => x.user_id == editAdmin.id).ToList(); entities.communusers.RemoveRange(comxuserAnterior); entities.SaveChanges(); foreach (var item in communityID) { long itemID = Convert.ToInt64(item); communuser communuserResult = entities.communusers.Where(m => m.user_id == editAdmin.id && m.commun_id == itemID).FirstOrDefault(); if (communuserResult == null) { communuser communuser = new communuser(); communuser.user_id = editAdmin.id; communuser.commun_id = itemID; entities.communusers.Add(communuser); entities.SaveChanges(); } } } else { List <communuser> comxuserAnterior = entities.communusers.Where(x => x.user_id == editAdmin.id).ToList(); foreach (var item in comxuserAnterior) { entities.communusers.Remove(item); entities.SaveChanges(); } } return(Redirect(Url.Action("listado", "administradores", new { area = "webmaster" }))); } catch (Exception ex) { return(Redirect(Url.Action("editar", "administradores", new { area = "webmaster", id = adminID, Error = "Error al editar el administrador: " + ex.Message }))); } }
public async Task <ActionResult> newadmin(HttpPostedFileBase user_logo, string first_name1, string last_name1, string mother_last_name1, string email, string password, List <string> communityID ) { try { string emailTemplate = ""; long userId = (long)Session["USER_ID"]; user curUser = entities.users.Find(userId); user newAdmin = new user(); newAdmin.is_active = true; newAdmin.acq_date = DateTime.Now; newAdmin.role = 2; newAdmin.first_name1 = first_name1; newAdmin.last_name1 = last_name1; newAdmin.mother_last_name1 = mother_last_name1; newAdmin.email = email; newAdmin.password = ep.Encrypt(password); newAdmin.create_userid = userId; if (user_logo != null && user_logo.ContentLength > 0) { var fileName = Path.GetFileName(user_logo.FileName); if (!Directory.Exists(Path.Combine(Server.MapPath("~/"), "Upload"))) { Directory.CreateDirectory(Path.Combine(Server.MapPath("~/"), "Upload")); } if (!Directory.Exists(Path.Combine(Server.MapPath("~/Upload/"), "User_Logo"))) { Directory.CreateDirectory(Path.Combine(Server.MapPath("~/Upload/"), "User_Logo")); } // store the file inside ~/App_Data/uploads folder var path = Path.Combine(Server.MapPath("~/Upload/User_Logo"), fileName); user_logo.SaveAs(path); newAdmin.user_img = fileName; } entities.users.Add(newAdmin); entities.SaveChanges(); if (communityID != null) { foreach (var item in communityID) { communuser communuser = new communuser(); communuser.user_id = newAdmin.id; communuser.commun_id = long.Parse(item); entities.communusers.Add(communuser); entities.SaveChanges(); } } //community community = entities.communities.Find(communityID); //community.is_active = true; string patialView = "~/Views/iniciar/emailing.cshtml"; emailingViewModel viewModel = new emailingViewModel(); viewModel.firstName = first_name1; viewModel.lastName = last_name1; viewModel.fromEmail = curUser.email; viewModel.toEmail = email; emailTemplate = ViewRenderer.RenderPartialView(patialView, viewModel); int a = await ep.SendAlertEmail(curUser.email, email, curUser.first_name1 + " " + curUser.last_name1, "añadir coadmin", "has sido añadido como coadmin\n password: "******"listado", "administradores", new { area = "webmaster" }))); } catch (Exception ex) { return(Redirect(Url.Action("agregar", "administradores", new { area = "webmaster", Error = "Error al agregar nuevo administrador: " + ex.Message }))); } }