public ActionResult addbook(string first_name, string description, string start_time, string end_time, string requested_date, string cost_per_reserve) { try { book newBook = new book(); newBook.first_name = first_name; newBook.start_time = TimeSpan.ParseExact(start_time, "h\\:mm", System.Globalization.CultureInfo.CurrentCulture, TimeSpanStyles.None); newBook.end_time = TimeSpan.ParseExact(end_time, "h\\:mm", System.Globalization.CultureInfo.CurrentCulture, TimeSpanStyles.None); newBook.requested_date = DateTime.ParseExact(requested_date, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture); newBook.description = description; newBook.cost_per_reservation = Convert.ToDecimal(cost_per_reserve); newBook.created_at = DateTime.Now; entities.books.Add(newBook); entities.SaveChanges(); return(Redirect(Url.Action("reservar", "facilidades", new { area = "webmaster" }))); } catch (Exception ex) { return(Redirect(Url.Action("reservartwo", "facilidades", new { area = "coadmin", exception = ex.Message }))); } }
public ActionResult editaviso(string aviso) { try { long userId = (long)Session["USER_ID"]; List <uso> usoList = entities.usoes.Where(m => m.create_userid == userId).ToList(); if (usoList.Count > 0) { uso editUso = usoList.First(); editUso.updated_at = DateTime.Now; editUso.aviso = aviso; } else { uso newUso = new uso(); newUso.created_at = DateTime.Now; newUso.updated_at = DateTime.Now; newUso.aviso = aviso; newUso.create_userid = userId; entities.usoes.Add(newUso); } entities.SaveChanges(); return(Redirect(Url.Action("aviso", "uso", new { area = "coadmin" }))); } catch (Exception ex) { return(Redirect(Url.Action("aviso", "uso", new { area = "coadmin", exceptio = ex.Message }))); } }
public JsonResult SetCommentSupplier(long supplierID, string commentary) { try { long userId = (long)Session["USER_ID"]; user curUser = entities.users.Find(userId); supplier supplier = entities.suppliers.Find(supplierID); comment comment = entities.comments.Where(m => m.supplier_id == supplierID && m.user_id == userId).FirstOrDefault(); if (comment == null) { comment = new comment(); comment.user_id = userId; comment.supplier_id = supplierID; comment.commentary = commentary; comment.created_at = DateTime.Now; comment.user_name = curUser.first_name1 + " " + curUser.last_name1; entities.comments.Add(comment); } else { comment.commentary = commentary; comment.created_at = DateTime.Now; comment.user_name = curUser.first_name1 + " " + curUser.last_name1; } entities.SaveChanges(); return(Json(new { result = "success" })); } catch (Exception) { return(Json(new { result = "error" })); } }
public ActionResult logout() { try { long userId; if (Session.Keys.Count == 0 || string.IsNullOrEmpty(Session["USER_ID"] as string)) { HttpCookie userIdCookie = Request.Cookies.Get("UserID"); userId = Convert.ToInt64(userIdCookie.Value); user curUser = entities.users.Find(userId); curUser.is_logged = false; } else { userId = (long)Session["USER_ID"]; user curUser = entities.users.Find(userId); curUser.is_logged = false; } entities.SaveChanges(); Session.RemoveAll(); } catch (Exception ex) { } return(Redirect(ep.GetLogoutUrl())); }
public void Connect(string userID)//string userName, string email { string userName = "", email = ""; var connectionId = Context.ConnectionId; long uID = Convert.ToInt64(userID); user curUser = entities.users.Find(uID); userName = curUser.first_name1 + " " + curUser.last_name1; email = curUser.email; using (pjrdev_condominiosEntities dc = new pjrdev_condominiosEntities()) { var item = dc.onlineusers.FirstOrDefault(x => x.user_id == uID); if (item != null) { item.connectionID = connectionId; item.updated_at = DateTime.Now; item.first_name = curUser.first_name1; item.last_name = curUser.last_name1; item.user_img = null; //curUser.user_img; item.is_active = true; item.is_online = true; dc.SaveChanges(); // Disconnect //Clients.All.onUserDisconnectedExisting(item.ConnectionId, item.UserName); // send to caller var connectedUsers = dc.onlineusers.Where(m => m.user_id != uID && m.is_online == true).ToList(); var CurrentMessage = dc.chatmessages.Where(m => m.from_user_id == uID || m.to_user_id == uID).ToList(); Clients.Caller.onConnected(connectionId, userName); } var users = dc.onlineusers.ToList(); if (users.Where(x => x.user_id == uID).ToList().Count == 0) { var userdetails = new onlineuser { connectionID = connectionId, user_id = uID, is_online = true, is_active = true, created_at = DateTime.Now, updated_at = DateTime.Now }; dc.onlineusers.Add(userdetails); dc.SaveChanges(); // send to caller var connectedUsers = dc.onlineusers.Where(m => m.user_id != uID && m.is_online == true).ToList(); var CurrentMessage = dc.chatmessages.Where(m => m.from_user_id == uID || m.to_user_id == uID).ToList(); Clients.Caller.onConnected(connectionId, userName); } // send to all except caller client Clients.AllExcept(connectionId).onNewUserConnected(connectionId, userName, email); } }
public JsonResult DeleteEvent(long delID) { try { @event delEvent = entities.events.Find(delID); entities.events.Remove(delEvent); entities.SaveChanges(); return(Json(new { result = "success" })); } catch (Exception ex) { return(Json(new { result = "error", exception = ex.HResult })); } }
public ActionResult logout() { try { long userId = (long)Session["USER_ID"]; user curUser = entities.users.Find(userId); curUser.is_logged = false; entities.SaveChanges(); Session.RemoveAll(); } catch (Exception ex) { } return(Redirect(ep.GetLogoutUrl())); }
public ActionResult reservarFacilidad(long idFacilidad, string dateFaci, string fechaDisponible) { try { long userId = (long)Session["USER_ID"]; TimeSpan masU = TimeSpan.FromHours(1); efac facility = entities.efacs.Find(idFacilidad); book newBook = new book(); newBook.first_name = facility.first_name; int horaSelectd = Convert.ToInt32(fechaDisponible); TimeSpan start_time = TimeSpan.FromHours(horaSelectd); TimeSpan end_time = TimeSpan.FromHours(horaSelectd); newBook.start_time = start_time; newBook.end_time = end_time.Add(masU); newBook.status = 1; newBook.requested_date = DateTime.ParseExact(dateFaci, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture); newBook.description = facility.description; newBook.cost_per_reservation = facility.cost_reservation; newBook.id_efac = idFacilidad; newBook.created_at = DateTime.Now; newBook.community_id = facility.community_id; newBook.idUser = userId; entities.books.Add(newBook); entities.SaveChanges(); return(Redirect(Url.Action("reservas", "facilidades"))); } catch (Exception ex) { return(Redirect(Url.Action("reservar", "facilidades", new { Error = "Problema interno " + ex.Message }))); } }
public List <task> GetNotifiTaskList(long userID) { List <task> taskList = new List <task>(); taskuser taskuser = entities.taskusers.Where(m => m.user_id == userID).FirstOrDefault(); if (taskuser == null) { taskuser = new taskuser(); taskuser.user_id = userID; taskuser.task_list = null; entities.taskusers.Add(taskuser); entities.SaveChanges(); } else { string taskListStr = taskuser.task_list; if (taskListStr != null) { string[] taskIDList = taskListStr.Split(','); for (int i = 0; i < taskIDList.Length; i++) { long taskID = Convert.ToInt64(taskIDList[i]); task taskItem = entities.tasks.Find(taskID); taskList.Add(taskItem); } } } return(taskList); }
public ActionResult editcontract(long contractID, string first_name, string date_contract, string date_notification, HttpPostedFileBase upload_contract, string description, int status) { try { contract editContract = entities.contracts.Find(contractID); editContract.first_name = first_name; editContract.date_contract = DateTime.ParseExact(date_contract, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture ); editContract.date_notification = DateTime.ParseExact(date_notification, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture ); editContract.description = description; if (upload_contract != null && upload_contract.ContentLength > 0) { var fileName = Path.GetFileName(upload_contract.FileName); if (!Directory.Exists(Path.Combine(Server.MapPath("~/"), "Upload"))) { Directory.CreateDirectory(Path.Combine(Server.MapPath("~/"), "Upload")); } if (!Directory.Exists(Path.Combine(Server.MapPath("~/Upload/"), "Regulation"))) { Directory.CreateDirectory(Path.Combine(Server.MapPath("~/Upload/"), "Regulation")); } var path = Path.Combine(Server.MapPath("~/Upload/Upload_Contract"), fileName); upload_contract.SaveAs(path); editContract.upload_contract = fileName; } editContract.status = status; entities.SaveChanges(); if (status == 1) { return(Redirect(Url.Action("listado", "contratos", new { area = "coadmin" }))); } else { return(Redirect(Url.Action("archivados", "contratos", new { area = "coadmin" }))); } }catch (Exception ex) { return(Redirect(Url.Action("editar", "contratos", new { area = "coadmin", id = contractID, Error = "Problema interno " + ex.Message }))); } }
public ActionResult newcommunity(string first_name, string description, long packageId, string apartment) { try { community newCommunity = new community(); newCommunity.first_name = first_name; // newCommunity.admin_email = admin_email; newCommunity.package_id = packageId; newCommunity.description = description; newCommunity.created_at = DateTime.Now; newCommunity.apart = apartment; newCommunity.is_active = false; entities.communities.Add(newCommunity); entities.SaveChanges(); return(Redirect(Url.Action("listado", "comunidades", new { area = "webmaster" }))); } catch (Exception ex) { return(Redirect(Url.Action("agregar", "comunidades", new { area = "webmaster", Error = "Error al agregar " + ex.Message }))); } }
public ActionResult newwebmaster(HttpPostedFileBase user_logo, string first_name1, string last_name1, string mother_last_name1, string email, string password ) { try { long userId = (long)Session["USER_ID"]; user newAdmin = new user(); newAdmin.is_active = true; newAdmin.acq_date = DateTime.Now; newAdmin.role = 3; 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); 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; } newAdmin.create_userid = userId; entities.users.Add(newAdmin); entities.SaveChanges(); return(Redirect(Url.Action("listado", "webmaster", new { area = "webmaster" }))); } catch (Exception ex) { return(Redirect(Url.Action("agregar", "webmaster", new { area = "webmaster", exception = ex.Message }))); } }
public JsonResult DeleteMessage(long selUserId, long messageId) { long uID = selUserId; long curId = (long)Session["USER_ID"]; List <chatmessage> chatmessageList = new List <chatmessage>(); selUserViewModel viewModel = new selUserViewModel(); try { chatmessage chatmessage = entities.chatmessages.Find(messageId); entities.chatmessages.Remove(chatmessage); entities.SaveChanges(); user curUser = entities.users.Find(curId); onlineuser selUser = entities.onlineusers.Where(m => m.user_id == uID).FirstOrDefault(); chatmessageList = entities.chatmessages.Where( m => (m.from_user_id == curId && m.to_user_id == uID) || (m.from_user_id == uID && m.to_user_id == curId)).ToList(); viewModel.chatmessageList = chatmessageList; string patialView = "~/Views/comunicaciones/_chatbox.cshtml"; viewModel.curUser = curUser; viewModel.selUser = selUser; string postsHtml = ViewRenderer.RenderPartialView(patialView, viewModel); return(Json(new { result = "success", html = postsHtml, })); } catch (Exception ex) { user curUser = entities.users.Find(curId); onlineuser selUser = entities.onlineusers.Where(m => m.user_id == uID).FirstOrDefault(); chatmessageList = entities.chatmessages.Where( m => (m.from_user_id == curId && m.to_user_id == uID) || (m.from_user_id == uID && m.to_user_id == curId)).ToList(); viewModel.chatmessageList = chatmessageList; viewModel.curUser = curUser; viewModel.selUser = selUser; string patialView = "~/Views/comunicaciones/_chatbox.cshtml"; string postsHtml = ViewRenderer.RenderPartialView(patialView, viewModel); return(Json(new { result = "error", html = postsHtml, exception = ex.Message })); } }
public ActionResult editcontact(long contactID, string company_admin, string coordinator, string president, string vice_president, string treasurer, string secretary, string vocal1, string vocal2, string vocal3, string phy_address, string postal_address, string phone_number1, string phone_number2, string email ) { try { long communityAct = Convert.ToInt64(Session["CURRENT_COMU"]); long user_id = (long)Session["USER_ID"]; contactinfo contactinfo = entities.contactinfoes.Find(contactID); contactinfo.company_admin = company_admin; contactinfo.coordinator = coordinator; contactinfo.president = president; contactinfo.vice_president = vice_president; contactinfo.treasurer = treasurer; contactinfo.secretary = secretary; contactinfo.vocal1 = vocal1; contactinfo.vocal2 = vocal2; contactinfo.vocal3 = vocal3; contactinfo.phy_address = phy_address; contactinfo.postal_address = postal_address; contactinfo.phone_number1 = phone_number1; contactinfo.phone_number2 = phone_number2; contactinfo.email = email; contactinfo.user_id = user_id; entities.SaveChanges(); return(Redirect(Url.Action("listado", "contacto", new { area = "coadmin" }))); } catch (Exception ex) { return(Redirect(Url.Action("editar", "contacto", new { area = "coadmin", exception = ex.Message }))); } }
public ActionResult AddEmaulTheme(string typeID, string content) { try { long userID = (long)Session["USER_ID"]; emailtheme emailtheme = new emailtheme(); emailtheme.type_id = Convert.ToInt32(typeID); emailtheme.htmcontent = content; emailtheme.user_id = userID; entities.emailthemes.Add(emailtheme); entities.SaveChanges(); return(Redirect(Url.Action("listado", "plantillas", new { area = "coadmin" }))); }catch (Exception ex) { return(Redirect(Url.Action("crear", "plantillas", new { area = "coadmin", exception = ex.Message }))); } }
public ActionResult editevent(long editID, string name, string event_date, string event_time, string place, string description, string note, int share) { try { long communityAct = Convert.ToInt64(Session["CURRENT_COMU"]); @event editevent = entities.events.Find(editID); editevent.name = name; editevent.place = place; editevent.event_date = DateTime.ParseExact(event_date + " " + event_time, "yyyy-MM-dd HH:mm", System.Globalization.CultureInfo.CurrentCulture); editevent.description = description; editevent.note = note; editevent.share = share; entities.SaveChanges(); return(Redirect(Url.Action("registrados", "eventos", new { area = "coadmin" }))); } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } return(Redirect(Url.Action("editar", "eventos", new { area = "coadmin", editID = editID }))); } }
public ActionResult editsupplier(long editID, HttpPostedFileBase supply_logo, string company, string contact_name, string type_service, int category, string address, string phone, string email, string supplier_from, string web_page, int status) { try { supplier supplier = entities.suppliers.Find(editID); if (supply_logo != null && supply_logo.ContentLength > 0) { var fileName = Path.GetFileName(supply_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/"), "Supplier_Logo"))) { Directory.CreateDirectory(Path.Combine(Server.MapPath("~/Upload/"), "Supplier_Logo")); } var path = Path.Combine(Server.MapPath("~/Upload/Supplier_Logo"), fileName); supply_logo.SaveAs(path); supplier.logo = fileName; } supplier.company = company; supplier.contact_name = contact_name; supplier.type_service = type_service; supplier.category_id = category; supplier.address = address; supplier.phone = phone; supplier.email = email; supplier.status = status; supplier.supplier_from = DateTime.ParseExact(supplier_from, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture); supplier.web_page = web_page; entities.SaveChanges(); return(Redirect(Url.Action("listado", "suplidores", new { area = "webmaster" }))); } catch (Exception ex) { return(Redirect(Url.Action("editar", "suplidores", new { area = "webmaster", exception = ex.Message }))); } }
public JsonResult DeletePackage(long delID) { try { List <community> supplidr = entities.communities.Where(x => x.package_id == delID).ToList(); if (supplidr.Count == 0) { package pacItem = entities.packages.Find(delID); entities.packages.Remove(pacItem); entities.SaveChanges(); return(Json(new { result = "success" })); } else { return(Json(new { result = "NotAlowed" })); } } catch (Exception ex) { return(Json(new { result = "error", exception = ex.HResult })); } }
private void DeletePrivateMessage(long delMessageId) { try { using (pjrdev_condominiosEntities dc = new pjrdev_condominiosEntities()) { chatmessage chatmessage = dc.chatmessages.Find(delMessageId); dc.chatmessages.Remove(chatmessage); dc.SaveChanges(); } } catch (Exception ex) { } }
public ActionResult newblogcomentario(string comment, long blogID) { try { blogcomment blogcomment = new blogcomment(); blog blog = entities.blogs.Find(blogID); long userId = (long)Session["USER_ID"]; user curUser = entities.users.Find(userId); blogcomment.name = curUser.first_name1 + " " + curUser.last_name1; blogcomment.comment = comment; blogcomment.blog_id = blogID; blogcomment.postdate = DateTime.Now; entities.blogcomments.Add(blogcomment); entities.SaveChanges(); return(Redirect(Url.Action("verblog", "comunicaciones", new { area = "webmaster", blogID = blogID }))); } catch (Exception) { return(Redirect(Url.Action("agregarcomentario", "comunicaciones", new { area = "webmaster", blogID = blogID }))); } }
public ActionResult newtask(string task_name, string description, string responsable, string task_date, string task_time, string comments, int share, int status, string estimated_date, string estimated_time ) { try { long userId = (long)Session["USER_ID"]; task newTask = new task(); newTask.task_name = task_name; newTask.description = description; newTask.responsable = responsable; newTask.comments = comments; newTask.task_date = DateTime.ParseExact(task_date + " " + task_time, "yyyy-MM-dd HH:mm", System.Globalization.CultureInfo.CurrentCulture); newTask.estimated_date = DateTime.ParseExact(estimated_date + " " + estimated_time, "yyyy-MM-dd HH:mm", System.Globalization.CultureInfo.CurrentCulture); newTask.share = share; newTask.status = status; newTask.created_at = DateTime.Now; newTask.updated_at = DateTime.Now; newTask.community_id = Convert.ToInt64(Session["CURRENT_COMU"]); entities.tasks.Add(newTask); entities.SaveChanges(); taskuser taskuser = entities.taskusers.Where(m => m.user_id == userId).FirstOrDefault(); if (taskuser == null) { taskuser = new taskuser(); taskuser.user_id = userId; taskuser.task_list = newTask.id.ToString(); entities.taskusers.Add(taskuser); } else { string taskList = taskuser.task_list; if (taskList == null) { taskuser.task_list = newTask.id.ToString(); } else { taskuser.task_list = taskList + "," + newTask.id.ToString(); } } entities.SaveChanges(); return(Redirect(Url.Action("listado", "tareas", new { area = "coadmin" }))); }catch (Exception) { return(Redirect(ep.GetLogoutUrl())); } }
public ActionResult editdocumenttype(int typeID, string type_name, int documentTypeShare) { try { document_type editDocumentType = entities.document_type.Find(typeID); editDocumentType.type_name = type_name; editDocumentType.share = documentTypeShare; entities.SaveChanges(); return(Redirect(Url.Action("listadoCategoria", "documentos", new { area = "coadmin" }))); } catch (Exception ex) { return(Redirect(Url.Action("editarCategoria", "documentos", new { area = "coadmin", typeID = typeID, Error = "Error al editar la categoría: " + ex.Message }))); } }
public void SaveUserOnlineStatus(onlineuser obj) { var query = entities.onlineusers.Where(m => m.user_id == obj.user_id && m.is_active == true && m.connectionID == obj.connectionID).FirstOrDefault(); if (obj != null) { query.is_online = obj.is_online; query.updated_at = DateTime.Now; query.connectionID = obj.connectionID; } else { obj.created_at = DateTime.Now; obj.updated_at = DateTime.Now; obj.is_active = true; entities.onlineusers.Add(obj); } entities.SaveChanges(); }
private long AddPrivateMessageinCache(long fromUserId, long toUserId, string message, bool isEmail, bool isRead) { using (pjrdev_condominiosEntities dc = new pjrdev_condominiosEntities()) { // Save details var chatmessage = new chatmessage { from_user_id = fromUserId, to_user_id = toUserId, message = message, created_at = DateTime.Now, updated_at = DateTime.Now, viewed_at = DateTime.Now, is_active = true, status = "Sent", is_email = isEmail, is_read = isRead }; dc.chatmessages.Add(chatmessage); dc.SaveChanges(); return(chatmessage.id); } }
public override Task OnDisconnected(bool stopCalled) { using (pjrdev_condominiosEntities dc = new pjrdev_condominiosEntities()) { string userName = ""; var connectionID = Context.ConnectionId; var item = dc.onlineusers.FirstOrDefault(x => x.connectionID == connectionID); if (item != null) { long uID = item.user_id; user curUser = entities.users.Find(uID); userName = curUser.first_name1 + " " + curUser.last_name1; item.is_online = false; onlineuser onlineuserItem = dc.onlineusers.Where(m => m.user_id == uID).FirstOrDefault(); if (onlineuserItem != null) { onlineuserItem.is_online = false; onlineuserItem.connectionID = connectionID; onlineuserItem.updated_at = DateTime.Now; } else { onlineuserItem = new onlineuser(); onlineuserItem.user_id = uID; onlineuserItem.connectionID = connectionID; onlineuserItem.is_online = false; onlineuserItem.created_at = DateTime.Now; onlineuserItem.updated_at = DateTime.Now; dc.onlineusers.Add(onlineuserItem); } dc.SaveChanges(); Clients.All.onUserDisconnected(connectionID, userName); } } return(base.OnDisconnected(stopCalled)); }
public ActionResult editfee(long feedId, string fee_name, string cost, string taxCharge, string penalty, long bank_id, string merchant_account) { long userId = (long)Session["USER_ID"]; fee feeItem = entities.fees.Find(feedId); if (feeItem != null) { feeItem.name = fee_name; feeItem.cost = Convert.ToDecimal(cost); feeItem.bank_id = bank_id; feeItem.merchant_account = merchant_account; feeItem.tax_charge = Convert.ToDecimal(taxCharge); feeItem.penalty = Convert.ToDecimal(penalty); entities.SaveChanges(); return(Redirect(Url.Action("listado", "cuotas", new { area = "coadmin" }))); } else { return(Redirect(ep.GetLogoutUrl())); } }
public ActionResult editdocumenttype(int typeID, string type_name) { try { document_type editDocumentType = entities.document_type.Find(typeID); editDocumentType.type_name = type_name; entities.SaveChanges(); return(Redirect(Url.Action("editarcategoria", "documentos", new { area = "webmaster", typeID = typeID }))); } catch (Exception ex) { return(Redirect(Url.Action("editarcategoria", "documentos", new { area = "webmaster", typeID = typeID, exception = ex.Message }))); } }
public ActionResult editprofile(HttpPostedFileBase user_logo, string email, string password, string acq_date, string first_name1, string last_name1, string mother_last_name1, string first_name2, string last_name2, string mother_last_name2, string phone_nmuber1, string phone_number2, string postal_address, string residential_address, HttpPostedFileBase upload_writing, string siono, string since, string until, string tenant_first_name1, string tenant_last_name1, string tenant_mother_last_name1, string tenant_first_name2, string tenant_last_name2, string tenant_mother_last_name2, string leased_postal_address, string leased_residential_address, HttpPostedFileBase leased_upload_file, string brand, string model, string colour, string year, string clapboard, string stamp_number ) { try { long userId = (long)Session["USER_ID"]; user user_s = entities.users.Find(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); user_s.user_img = fileName; } if (acq_date != "0001-01-01") { user_s.acq_date = DateTime.ParseExact(acq_date, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture); } user_s.email = email; user_s.password = ep.Encrypt(password); user_s.first_name1 = first_name1; user_s.first_name2 = first_name2; user_s.last_name1 = last_name1; user_s.last_name2 = last_name2; user_s.mother_last_name1 = mother_last_name1; user_s.mother_last_name2 = mother_last_name2; user_s.phone_number1 = phone_nmuber1; user_s.phone_number2 = phone_number2; user_s.postal_address = postal_address; user_s.residential_address = residential_address; if (upload_writing != null && upload_writing.ContentLength > 0) { var fileName = Path.GetFileName(upload_writing.FileName); if (!Directory.Exists(Path.Combine(Server.MapPath("~/"), "Upload"))) { Directory.CreateDirectory(Path.Combine(Server.MapPath("~/"), "Upload")); } if (!Directory.Exists(Path.Combine(Server.MapPath("~/Upload/"), "Upload_Writing"))) { Directory.CreateDirectory(Path.Combine(Server.MapPath("~/Upload/"), "Upload_Writing")); } // store the file inside ~/App_Data/uploads folder var path = Path.Combine(Server.MapPath("~/Upload/Upload_Writing"), fileName); upload_writing.SaveAs(path); user_s.upload_writing = fileName; } user_s.tenant_first_name1 = tenant_first_name1; user_s.tenant_first_name2 = tenant_first_name2; user_s.tenant_last_name1 = tenant_last_name1; user_s.tenant_last_name2 = tenant_last_name2; user_s.tenant_mother_last_name1 = tenant_mother_last_name1; user_s.tenant_mother_last_name2 = tenant_mother_last_name2; user_s.leased_postal_address = leased_postal_address; user_s.leased_residential_address = leased_residential_address; user_s.siono = siono; user_s.brand = brand; user_s.model = model; if (year != "") { user_s.year = Convert.ToInt32(year); } else { user_s.year = null; } user_s.clapboard = clapboard; if (stamp_number != "") { user_s.stamp_number = Convert.ToInt32(stamp_number); } else { user_s.stamp_number = null; } if (since == "0001-01-01") { user_s.since = null; } else { user_s.since = DateTime.ParseExact(since, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture); } if (until == "0001-01-01") { user_s.until = null; } else { user_s.until = DateTime.ParseExact(until, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture); } if (leased_upload_file != null && leased_upload_file.ContentLength > 0) { var fileName = Path.GetFileName(leased_upload_file.FileName); if (!Directory.Exists(Path.Combine(Server.MapPath("~/"), "Upload"))) { Directory.CreateDirectory(Path.Combine(Server.MapPath("~/"), "Upload")); } if (!Directory.Exists(Path.Combine(Server.MapPath("~/Upload/"), "Upload_Contract"))) { Directory.CreateDirectory(Path.Combine(Server.MapPath("~/Upload/"), "Upload_Contract")); } // store the file inside ~/App_Data/uploads folder var path = Path.Combine(Server.MapPath("~/Upload/Upload_Contract"), fileName); leased_upload_file.SaveAs(path); user_s.user_img = fileName; } //user_s.since = since; entities.SaveChanges(); return(Redirect(Url.Action("panel", "control"))); } catch (Exception) { return(Redirect(Url.Action("perfil", "administrador"))); } }
public async Task <ActionResult> MakePayment(decimal cost, decimal taxCharge, decimal penalty) { try { long communityAct = Convert.ToInt64(Session["CURRENT_COMU"]); string paymentType = "CC"; // CreditCard bool makePayment = false; long userId = (long)Session["USER_ID"]; user curUser = entities.users.Find(userId); long adminId = (long)curUser.create_userid; fee feeItem = entities.fees.Where(m => m.user_id == adminId && m.community_id == communityAct).FirstOrDefault(); bank adminBankItem = entities.banks.Find(feeItem.bank_id); string bank_account = adminBankItem.account_number; string routing_number = adminBankItem.route_number; string account_name = adminBankItem.account_name; user adminUser = entities.users.Find(adminId); decimal totalAmount = cost + taxCharge + penalty; creditcard creditcardItem = entities.creditcards.Where(m => m.user_id == userId).FirstOrDefault(); StripeConfiguration.SetApiKey(ep.GetStripeSecretKey()); if (creditcardItem != null) { DateTime expire_date = (DateTime)creditcardItem.expiration_date; var options = new TokenCreateOptions { Card = new CreditCardOptions { Number = creditcardItem.card_number, //"4000 0000 0000 0077", //creditcardItem.card_number,//"4242424242424242" ExpYear = expire_date.Year, //2020 ExpMonth = expire_date.Month, Cvc = creditcardItem.ccv } }; var service = new TokenService(); Token stripeToken = service.Create(options); int pc = await PaymentCredit(stripeToken.Id, Convert.ToInt32(cost * 100), bank_account, routing_number, account_name); if (pc == 1) { paymentType = "CC"; makePayment = true; } } else { bank userBank = entities.banks.Where(m => m.user_id == userId).FirstOrDefault(); if (userBank != null) { var options = new TokenCreateOptions { BankAccount = new BankAccountOptions { Country = "US", Currency = "usd", AccountHolderName = userBank.account_name, //"Jenny Rosen" AccountHolderType = "individual", RoutingNumber = userBank.route_number, //"110000000" AccountNumber = userBank.account_number //"000123456789" } }; var service = new TokenService(); Token stripeToken = service.Create(options); int ach = await PaymentAch(stripeToken.Id, Convert.ToInt32(totalAmount * 100), bank_account, routing_number); if (ach == 1) { paymentType = "ACH"; makePayment = true; } } } if (makePayment == true) { transaction transItem = new transaction(); if (transItem.balance != null) { decimal originBalance = (decimal)transItem.balance; transItem.balance = originBalance + totalAmount; } else { transItem.balance = totalAmount; } transItem.credit = 0; transItem.debit = totalAmount; transItem.date_info = DateTime.Now; transItem.kind = "Factura"; transItem.state = "Factura"; transItem.trans_id = ""; entities.transactions.Add(transItem); payment paymentItem = new payment(); paymentItem.method = paymentType; paymentItem.date_issue = DateTime.Now; paymentItem.date_payment = null; paymentItem.email = adminUser.email; paymentItem.first_name = adminUser.first_name1; paymentItem.surname = adminUser.last_name1; paymentItem.to_user_id = adminId; paymentItem.quantity = totalAmount; paymentItem.user_id = userId; paymentItem.state = true; entities.payments.Add(paymentItem); entities.SaveChanges(); } return(Redirect(Url.Action("estado", "cuotas"))); } catch (Exception ex) { return(Redirect(Url.Action("balance", "cuotas"))); } }
public JsonResult PerformLogin(string email, string password, bool rememberme) { try { var response = HttpContext.Response; HttpCookie emailCookie = new HttpCookie("Email"); HttpCookie passwordCookie = new HttpCookie("Password"); HttpCookie userIdCookie = new HttpCookie("UserID"); if (rememberme == true) { emailCookie.Expires = DateTime.Now.AddDays(30); passwordCookie.Expires = DateTime.Now.AddDays(30); emailCookie.Value = email.Trim(); passwordCookie.Value = password.Trim(); } else { emailCookie.Expires = DateTime.Now.AddDays(-1); passwordCookie.Expires = DateTime.Now.AddDays(-1); } response.Cookies.Remove("Email"); response.Cookies.Remove("Password"); response.Cookies.Add(emailCookie); response.Cookies.Add(passwordCookie); List <user> result = new List <user>(); List <user> usernameResult = entities.users.Where(m => m.email == email).ToList(); password = ep.Encrypt(password); if (usernameResult.Count > 0) { user username_result_item = usernameResult.First(); if (string.Compare(email, username_result_item.email, StringComparison.CurrentCulture) == 0) { result = entities.users.Where(m => m.email == email).Where(m => m.password == password).ToList(); if (result.Count > 0) { user current_user = result[0]; if (string.Compare(password, current_user.password, StringComparison.CurrentCulture) == 0) { if (current_user.is_active) { Session["USER_ID"] = current_user.id; Session["USER_NAME"] = current_user.first_name1 + " " + current_user.last_name1; Session["USER_IMAGE"] = current_user.user_img; Session["USER_ADMIN"] = current_user.is_admin; Session["USER_ROLE"] = current_user.role; Session["Active"] = current_user.is_active; Session["CURRENT_COMU"] = null; userIdCookie.Expires = DateTime.Now.AddDays(100); userIdCookie.Value = current_user.id.ToString(); response.Cookies.Remove("UserID"); response.Cookies.Add(userIdCookie); current_user.is_logged = true; entities.SaveChanges(); return(Json(new { result = "success" })); } else { return(Json(new { result = "Lo sentimos, este usuario ha sido temporaremente desactivado" })); } } else { return(Json(new { result = "password is wrong" })); } } else { return(Json(new { result = "password is wrong" })); } } else { return(Json(new { result = "username does not exist" })); } } else { return(Json(new { result = "username does not exist" })); } } catch (Exception ex) { return(Json(new { result = "server is error", exception = ex.Message })); } }