public UserRepCollection Get2(String id) { UserRepCollection l1 = new UserRepCollection(); int did = Convert.ToInt32(id); l1 = new UserRepRepo().ListUserRepByDeptID(did); return(l1); }
public static UserRepCollection UpdateURcollectiontableUR(int DepID, int EmpID) // changed void return type to UserRepCollection return type { UserRepCollection s = _entities.UserRepCollection .Where(p => p.DepartmentID == DepID) .First <UserRepCollection>(); s.DepartmentID = DepID; s.EmployeeID = EmpID; _entities.SaveChanges(); return(s); }
public int UpdateUserRep(UserRepCollection req) { using (StationeryStoreEntities context = new StationeryStoreEntities()) { var q = context.UserRepCollections.Where(x => x.URCollectionID == req.URCollectionID).First(); if (q != null) { q.EmployeeID = req.EmployeeID; q.CollectionID = req.CollectionID; context.SaveChanges(); return(1); } return(0); }; }
protected void UpdateButton_Click(object sender, EventArgs e) { //int DepID = 2001; int DepID = (int)HttpContext.Current.Session["DeptID"]; int NewCollectionID = Convert.ToInt32(CPRadioButtonList.SelectedValue); UserRepCollection updatedDeptURCollection = new UserRepCollection { }; // must declare a variable here first before using it in try block or else not detectable try { updatedDeptURCollection = SupplierBizLogic.UpdateURcollectiontableCollection(DepID, NewCollectionID); // changed this to return a userrepcollection object Response.Write("<script>alert('Collection Point updated!');</script>"); } catch (Exception exp) { Response.Write(exp.ToString()); } // added code below: try { //to clerk string oldCollection = Label1.Text; String from = "*****@*****.**"; List <String> toAddress = MailBizLogic.ClerkEmail(); String subject = String.Format("[Auto Notification] Changes on Collection Point for {0}", updatedDeptURCollection.Department.Description); String body = String.Format("Collection Point For '{0}' has been changed from '{1}' to '{2}'." + "\n\nNote: This is an auto-generated email. Please do not reply to this email." + "\n\nThis email is confidential and may be privileged.If you are not the intended recipient, " + "please delete it and notify us immediately; you should not copy or use it for any purpose, " + "nor disclose its contents to any other person.\n\nThank you.", updatedDeptURCollection.Department.Description, oldCollection, updatedDeptURCollection.Collection.Location); foreach (String to in toAddress) { MailBizLogic.sendMail(from, to, subject, body); } BindData(DepID); } catch (Exception ex) { Response.Write("Could not send the e-mail - error: " + ex.Message); } }
protected void UpdateButton_Click(object sender, EventArgs e) { int DepID = (int)HttpContext.Current.Session["DeptID"]; int NewEmployeeID = Convert.ToInt32(URDropDownList.SelectedValue); //changed from CPRadioButtonList to URDropDownList int OldEmployeeID = Convert.ToInt32(SupplierBizLogic.FindCollectionByDepID(DepID).EmployeeID); UserRepCollection updatedDeptURCollection = new UserRepCollection { }; // must declare a variable here first before using it in try block or else not detectable try { SupplierBizLogic.UpdateNewURinEmptable(NewEmployeeID); SupplierBizLogic.UpdateOldURinEmptable(OldEmployeeID); updatedDeptURCollection = SupplierBizLogic.UpdateURcollectiontableUR(DepID, NewEmployeeID); Response.Write("<script>alert('User Representative changed!');</script>"); } catch (Exception exp) { Response.Write(exp.ToString()); } // added code below: try { String from = "*****@*****.**"; List <String> toAddress = MailBizLogic.ClerkEmail(); String subject = String.Format("[Auto Notification] Changes on User Representative for {0}", updatedDeptURCollection.Department.Description); String body = String.Format("New User Representative For '{0}' has been assigned to {1}." + "\n\nNote: This is an auto-generated email. Please do not reply to this email." + "\n\nThis email is confidential and may be privileged.If you are not the intended recipient, " + "please delete it and notify us immediately; you should not copy or use it for any purpose, " + "nor disclose its contents to any other person.\n\nThank you.", updatedDeptURCollection.Department.Description, updatedDeptURCollection.Employee.Name); foreach (String to in toAddress) { MailBizLogic.sendMail(from, to, subject, body); } Label2.Text = SupplierBizLogic.FindCollectionByDepID(DepID).EmployeeName.ToString(); } catch (Exception ex) { Response.Write("Could not send the e-mail - error: " + ex.Message); } }
public int update([FromBody] UserRepCollection e) { return(new UserRepRepo().UpdateUserRep(e)); }