public async Task <IHttpActionResult> RemoveCompanyConnection(long companyConnectionId) { string userName = User.Identity.Name; User user = db.Users.Where(_user => _user.UserName == userName) .Include(_user => _user.Company) .Include(_user => _user.Company.Followers) .SingleOrDefault(); if (user == null) { throw new HttpResponseException(HttpStatusCode.Unauthorized); } if (user.Company == null) { throw new HttpResponseException(HttpStatusCode.BadRequest); } CompanyConnection companyConnection = user.Company.Followers.Where(_companyConnection => _companyConnection.ID == companyConnectionId).SingleOrDefault(); if (companyConnection == null) { throw new HttpResponseException(HttpStatusCode.BadRequest); } db.CompanyConnections.Remove(companyConnection); await db.SaveChangesAsync(); return(Ok()); }
private void btnSave_Click(object sender, EventArgs e) { try { CompanyConnection objConnection = new CompanyConnection(); objConnection.Id = _id; objConnection.FK_CompanyID = cboCompany.EditValue.To <int>(); objConnection.Source = txtSource.Text; objConnection.Catalog = txtCatalog.Text; objConnection.UserName = txtUserName.Text; objConnection.Password = new Encryption(KeyEngypt).Encrypt(txtPassword.Text); if (!CheckValid()) { return; } if (_id == -1) { objConnection.Insert(); new MessageBoxBA().Show("Thêm mới thông tin máy chủ thành công!", "Thông báo", MessageBoxButtonsBA.OK, MessageBoxIconBA.Information); } else { objConnection.Update(); new MessageBoxBA().Show("Cập nhật thông tin máy chủ thành công!", "Thông báo", MessageBoxButtonsBA.OK, MessageBoxIconBA.Information); } btnRefresh.PerformClick(); } catch (Exception ex) { LogError.WriteLogError("btnSave_Click: ", ex); } }
public async Task <IHttpActionResult> AcceptCompanyConnection(long companyConnectionId) { string userName = User.Identity.Name; User user = db.Users.Where(_user => _user.UserName == userName) .Include(_user => _user.Company) .Include(_user => _user.Company.Followers) .SingleOrDefault(); if (user == null) { throw new HttpResponseException(HttpStatusCode.Unauthorized); } if (user.Company == null) { throw new HttpResponseException(HttpStatusCode.BadRequest); } CompanyConnection companyConnection = user.Company.Followers.Where(_companyConnection => _companyConnection.ID == companyConnectionId && _companyConnection.Status == ConnectionStatus.Pending).SingleOrDefault(); if (companyConnection == null) { throw new HttpResponseException(HttpStatusCode.BadRequest); } companyConnection.AcceptedAt = DateTime.Now; companyConnection.Status = ConnectionStatus.Accepted; db.Entry(companyConnection).State = EntityState.Modified; await db.SaveChangesAsync(); return(Ok()); }
private void btnDelete_Click(object sender, EventArgs e) { try { if (_id == -1) { new MessageBoxBA().Show("Bạn chưa chọn dữ liệu trên lưới!", "Thông báo", MessageBoxButtonsBA.OK, MessageBoxIconBA.Error); return; } var result = new MessageBoxBA().Show("Bạn có muốn xóa thông tin máy chủ này không?", "Thông báo", MessageBoxButtonsBA.YesNo, MessageBoxIconBA.Question); if (result == "Yes") { CompanyConnection objDel = new CompanyConnection(); objDel.Id = _id; objDel.Delete(); new MessageBoxBA().Show("Xóa thông tin máy chủ thành công!", "Thông báo", MessageBoxButtonsBA.OK, MessageBoxIconBA.Information); ResetForm(); RefreshGridControl(); } } catch (Exception ex) { LogError.WriteLogError("btnDelete_Click: ", ex); } }
public async Task <IHttpActionResult> RemoveFollowerFromGroup(long followerUserId, long followerGroupId) { string userName = User.Identity.Name; User user = db.Users.Where(_user => _user.UserName == userName).SingleOrDefault(); if (user == null) { throw new HttpResponseException(HttpStatusCode.Unauthorized); } CompanyFollowerGroup companyFollowerGroup = db.CompanyFollowerGroups.Where(_companyFollowerGroup => _companyFollowerGroup.ID == followerGroupId).SingleOrDefault(); if (companyFollowerGroup == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } if ((companyFollowerGroup.Company.Owner.Id != user.Id) && (companyFollowerGroup.Company.Members.Any(member => member.UserID == user.Id) == false)) { throw new HttpResponseException(HttpStatusCode.Unauthorized); } CompanyConnection companyConnection = companyFollowerGroup.Followers.Where(_follower => _follower.UserID == followerUserId).SingleOrDefault(); if (companyConnection == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } companyFollowerGroup.Followers.Remove(companyConnection); db.Entry(companyFollowerGroup).State = EntityState.Modified; await db.SaveChangesAsync(); return(Ok()); }
private bool CheckExistServer(CompanyConnection pServer) { string ipAddress = string.Empty; if (pServer.Source.Contains(",")) { ipAddress = NetworkInformation.FormatIP(pServer.Source, ","); } if (ipAddress.Length > 3) { if (NetworkInformation.PingHost(ipAddress)) { return(true); } } if (pServer.Source.Contains("\\")) { ipAddress = NetworkInformation.FormatIP(pServer.Source, "\\"); } if (ipAddress.Length > 3) { if (NetworkInformation.PingHost(ipAddress)) { return(true); } } if (NetworkInformation.PingHost(pServer.Source)) { return(true); } return(false); }
public async Task <IHttpActionResult> UpdateFollowerGroupsForFollower(UpdateFollowerGroupsForFollowerDTO updateFollowerGroupsForFollowerDTO) { string userName = User.Identity.Name; User user = db.Users.Where(_user => _user.UserName == userName) .Include(_user => _user.Company) .Include(_user => _user.Company.FollowerGroups) .SingleOrDefault(); if (user == null) { throw new HttpResponseException(HttpStatusCode.Unauthorized); } Company company = user.Company; if (company == null) { throw new HttpResponseException(HttpStatusCode.BadRequest); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } CompanyConnection follower = db.CompanyConnections.Where(_follower => _follower.UserID == updateFollowerGroupsForFollowerDTO.FollowerUserID && _follower.CompanyID == company.ID) .Include(_follower => _follower.FollowerGroups). SingleOrDefault(); if (follower == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } follower.FollowerGroups.Clear(); db.Entry(follower).State = EntityState.Modified; IEnumerable <CompanyFollowerGroup> followerGroupsToAdd = db.CompanyFollowerGroups.Where(followerGroup => followerGroup.CompanyID == company.ID && updateFollowerGroupsForFollowerDTO.FollowerGroupIDs.Contains(followerGroup.ID)); if (followerGroupsToAdd.Count() > 0) { foreach (CompanyFollowerGroup followerGroupToAdd in followerGroupsToAdd) { follower.FollowerGroups.Add(followerGroupToAdd); } } await db.SaveChangesAsync(); return(Ok(updateFollowerGroupsForFollowerDTO)); }
protected void Page_Load(object sender, EventArgs e) { if (Session["COMPANY"] == null) { Response.Redirect("~/Web/Account/tempLogin.aspx"); } string html = ""; CompanyConnection connection = new CompanyConnection(); Qaelo.Models.CompanyModel.Company company = (Qaelo.Models.CompanyModel.Company)Session["COMPANY"]; List <Qaelo.Models.CompanyModel.Job> jobs = connection.getAllPostByCompanyId(company.Id); foreach (Qaelo.Models.CompanyModel.Job item in jobs) { List <int> userIds = connection.getAllLikedUsers(item.Id, company.Id); html += string.Format(@"<h3 align='center'><a href='landlord-my-rooms.aspx'>List of users who like:{0} Post</a></h3> <table class='table responsive table-striped table-bordered' cellspacing='0' width='100%'> <thead> <tr> <th>Profile</th> <th>Name</th> <th>Email</th> <th>Number</th> </tr> </thead><tbody>", item.Title); foreach (int userId in userIds) { Qaelo.Models.StudentModel.Student s = new Data.Accounts.AccountConnection().getStudent(userId); html += string.Format(@" <tr> <td><img src='../../../Images/Users/Students/{0}' class='img-thumbnail' width='50' height='50' /></td> <td>{1}</td> <td>{2}</td> <td>{3}</td> </tr>", s.ProfileImage, s.FirstName + " " + s.LastName, s.Email, s.Number); } html += "</tbody></table><br/>"; } //if (html == "") html = "<div class='alert alert-info'><h3>I'ts Empty here, Data will soon be available as soon as your posts get interaction</div></h3>"; lblListOfUsers.Text = html; }
public List <DataModel.Customer> GetCustomerDetail(biz.models.enquiry.InquiryCriteriaDTO inquiryCriteriaDTO) { var dynp = new DynamicParameters(); dynp.Add("@ID", inquiryCriteriaDTO.CustomerID, DbType.String, ParameterDirection.Input); dynp.Add("@Email", inquiryCriteriaDTO.Email, DbType.String, ParameterDirection.Input); var enquiry = CompanyConnection.QueryMultiple("enq_CustomerDetail", dynp, commandType: CommandType.StoredProcedure); var customers = enquiry.Read <DataModel.Customer>().ToList(); var transactions = enquiry.Read <DataModel.Transaction>().ToList(); foreach (var customer in customers) { customer.transactions = transactions.Where(a => a.CustomerID == customer.CustomerID).ToList(); } return(customers); }
private void gridView_DoubleClick(object sender, EventArgs e) { try { CompanyConnection row = (CompanyConnection)gridView.GetFocusedRow(); if (row != null) { _id = row.Id; txtSource.Text = row.Source; txtCatalog.Text = row.Catalog; txtUserName.Text = row.UserName; txtPassword.Text = new Encryption(KeyEngypt).Decrypt(row.Password); cboCompany.EditValue = row.FK_CompanyID; } } catch (Exception ex) { LogError.WriteLogError("gridView_DoubleClick: ", ex); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["COMPANY"] == null) { Response.Redirect("~/Web/Account/tempLogin.aspx?page=Users/Company/EditPost.aspx"); } if (!IsPostBack) { //Get Company if (Request.QueryString["editId"] != null) { Qaelo.Models.CompanyModel.Job job = new CompanyConnection().getPostById(Convert.ToInt32(Request.QueryString["editId"])); txtADetails.Text = job.ContactInfo; txtDescription.Text = job.Description; txtCDate.Text = job.ClosingDate.ToShortDateString(); txtTitle.Text = job.Title; int index = 0; if (job.Type.ToUpper() == "JOB") { index = 2; } else if (job.Type.ToUpper() == "BURSARY") { index = 1; } ddlType.SelectedIndex = index; } else { lblErrorMessage.Text = ""; lblSuccess.Text = ""; } } }
public async Task <IHttpActionResult> AddCompanyConnection(long companyId) { string userName = User.Identity.Name; User user = db.Users.Where(_user => _user.UserName == userName).SingleOrDefault(); if (user == null) { throw new HttpResponseException(HttpStatusCode.Unauthorized); } Company company = db.Companies.Where(_company => _company.ID == companyId).Include(_company => _company.Owner).SingleOrDefault(); if (company == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } if (user.Company == company) { throw new HttpResponseException(HttpStatusCode.BadRequest); } CompanyConnection companyConnection = db.CompanyConnections.Where(_companyConnection => _companyConnection.CompanyID == companyId && _companyConnection.UserID == user.Id).SingleOrDefault(); if (companyConnection != null) { throw new HttpResponseException(HttpStatusCode.BadRequest); } companyConnection = new CompanyConnection(); companyConnection.UserID = user.Id; companyConnection.User = user; companyConnection.CompanyID = company.ID; companyConnection.Company = company; companyConnection.RequestedAt = DateTime.Now; companyConnection.Status = ConnectionStatus.Pending; companyConnection = db.CompanyConnections.Add(companyConnection); await db.SaveChangesAsync(); string connectionRequestUserName = user.UserName; if (user.FirstName != null || user.LastName != null) { connectionRequestUserName = (user.FirstName == null ? "" : user.FirstName) + " " + (user.LastName == null ? "" : user.LastName); } string companyOwnerUserName = company.Owner.UserName; if (company.Owner.FirstName != null || company.Owner.LastName != null) { companyOwnerUserName = (company.Owner.FirstName == null ? "" : company.Owner.FirstName) + " " + (company.Owner.LastName == null ? "" : company.Owner.LastName); } string connectionRequestUserCompanyName = user.Company == null ? "" : user.Company.DisplayName; string connectionRequestUserCompanyId = user.Company == null ? "" : user.Company.ID.ToString(); string apiKey = SENDGRID_API_KEY; SendGridClient sendGridClient = new SendGridClient(apiKey, "https://api.sendgrid.com"); EmailAddress emailSender = new EmailAddress("*****@*****.**", "Cervitt"); String subject = "Connection request"; EmailAddress emailRecipient = new EmailAddress(company.Owner.Email); Content content = new Content("text/html", "Hello world!"); SendGridMessage mail = MailHelper.CreateSingleEmail(emailSender, emailRecipient, subject, "", ""); mail.TemplateId = "c60b6b5e-4b1f-4cf3-b884-f69b4229947c"; mail.AddSubstitution("<%companyName%>", company.DisplayName); mail.AddSubstitution("<%companyOwnerUserName%>", companyOwnerUserName); mail.AddSubstitution("<%connectionRequestUserId%>", user.Id.ToString()); mail.AddSubstitution("<%connectionRequestUserName%>", connectionRequestUserName); mail.AddSubstitution("<%connectionRequestUserTitle%>", user.JobTitle); mail.AddSubstitution("<%connectionRequestUserCompanyName%>", connectionRequestUserCompanyName); mail.AddSubstitution("<%connectionRequestUserCompanyId%>", connectionRequestUserCompanyId); dynamic response = sendGridClient.SendEmailAsync(mail); return(Ok()); }
protected void Page_Load(object sender, EventArgs e) { if (Session["COMPANY"] == null) { Response.Redirect("~/Web/Account/tempLogin.aspx?page=Users/Company/ManagePostings.aspx"); } if (Request.QueryString["page"] != null) { if (Request.QueryString["page"].ToString() == "post") { lblSuccess.Text = "Successfully created a post"; } if (Request.QueryString["page"].ToString() == "editPost") { lblSuccess.Text = "Successfully Edited a post"; } } CompanyConnection connection = new CompanyConnection(); Qaelo.Models.CompanyModel.Company company = (Qaelo.Models.CompanyModel.Company)Session["COMPANY"]; if (Request.QueryString["delId"] != null) { if (connection.deletePost(Convert.ToInt32(Request.QueryString["delId"].ToString()), company.Id)) { lblSuccess.Text = "Post has been deleted successfuly"; } else { lblErrorMessage.Text = "An error occurred while deleting Post please try again"; } } List <Qaelo.Models.CompanyModel.Job> jobs = connection.getAllPostByCompanyId(company.Id); string html = ""; foreach (Qaelo.Models.CompanyModel.Job item in jobs) { html += string.Format(@"<div class='col-lg-3'> <div class='thumbnail'> <div class='w3-card-12'> <figure > <img src='../../../Images/Users/Company/{0}' class='' style='height:220px;width:100%'/> <figcaption style = 'background-image: url('')'>{1} </figcaption> </figure> <div class='w3-container' style='margin:10px'> <h6><b>{2} - <small>{3}</small></b></h6> <strong> Closing Date : <small> {4}</small></strong><br/> <strong> Date Posted: <small> {5}</small></strong><br/> </strong> <a href='ManagePostings.aspx?delId={6}' class='btn btn-danger pull-lef'>Delete</a> <a href='EditPost.aspx?editId={6}' class='btn btn-info pull-right'>Edit</a> </div> </div> </div> </div>", company.ProfileImage, item.Description, company.Name, item.Title, General.getDateString(item.ClosingDate), General.getPastTimeString(item.DatePosted), item.Id); } lblPosts.Text = html; }