public long Insert(long BasisID, long ID_Permission, DateTime CreatedOn, bool Active) { DataClasses1DataContext classes1DataContext = new DataClasses1DataContext(); WEBSERVICESBASIS entity = new WEBSERVICESBASIS(); entity.ID_Permission = ID_Permission; entity.CreatedOn = CreatedOn; entity.Active = Active; entity.ID_Basis = BasisID; classes1DataContext.WEBSERVICESBASIS.InsertOnSubmit(entity); classes1DataContext.SubmitChanges(); return(entity.ID); }
protected void GridviewOsnoviNaBaranje_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "DeleteWS") { long num = Convert.ToInt64(((WebControl)e.CommandSource).Attributes["1"]); List <BASIS> list1 = (List <BASIS>) this.Session["ListOsnoviSelected"]; List <BASIS> list2 = (List <BASIS>) this.Session["ListOsnoviSelected"]; List <BASIS> list3 = new List <BASIS>(); foreach (BASIS basis in list1) { if (basis.ID == num) { list1.Remove(basis); using (List <WEBSERVICESBASIS> .Enumerator enumerator = new WSBasisDAL().GetActiveByInstitutionWebServiceAndBasis(Convert.ToInt64(this.DropDonwListInstitution.SelectedValue), Convert.ToInt64(this.DropDownListServis.SelectedValue), basis.ID).GetEnumerator()) { while (enumerator.MoveNext()) { WEBSERVICESBASIS current = enumerator.Current; new WSBasisDAL().Update(new long?(), new long?(), new DateTime?(), new bool?(false), current.ID); string old = ""; string newone = ""; new LOGDAL().Insert(Enumerable.First <KeyValuePair <int, string> >((IEnumerable <KeyValuePair <int, string> >)InteropDAL.TablesDictionary, (Func <KeyValuePair <int, string>, bool>)(p => p.Value == "WEBSERVICESBASIS")).Key, (USER)this.Session["user"], current.ID.ToString(), 2, DateTime.Now, old, newone); } break; } } } this.Session["ListOsnoviSelected"] = (object)list1; this.GridviewOsnoviNaBaranje.DataBind(); } else { if (!(e.CommandName == "InsertWS")) { return; } BASIS byId = new BasisDAL().GetByID(Convert.ToInt64(((WebControl)e.CommandSource).Attributes["1"])); List <BASIS> list = (List <BASIS>) this.Session["ListOsnoviSelected"]; list.Add(byId); foreach (PERMISSION permission in new PermissionsDAL().GetPermisionsByInstitutionandWebService(Convert.ToInt64(this.DropDonwListInstitution.SelectedValue), Convert.ToInt64(this.DropDownListServis.SelectedValue))) { long num = new WSBasisDAL().Insert(byId.ID, permission.ID, DateTime.Now, true); string old = ""; string newone = ""; new LOGDAL().Insert(Enumerable.First <KeyValuePair <int, string> >((IEnumerable <KeyValuePair <int, string> >)InteropDAL.TablesDictionary, (Func <KeyValuePair <int, string>, bool>)(d => d.Value == "WEBSERVICESBASIS")).Key, (USER)this.Session["user"], num.ToString(), 2, DateTime.Now, old, newone); } this.Session["ListOsnoviSelected"] = (object)list; this.GridviewOsnoviNaBaranje.DataBind(); } }
public void Update(long?BasisID, long?ID_Permission, DateTime?CreatedOn, bool?Active, long id) { DataClasses1DataContext classes1DataContext = new DataClasses1DataContext(); WEBSERVICESBASIS webservicesbasis = Queryable.Single <WEBSERVICESBASIS>((IQueryable <WEBSERVICESBASIS>)classes1DataContext.WEBSERVICESBASIS, (Expression <Func <WEBSERVICESBASIS, bool> >)(p => p.ID == id)); if (BasisID.HasValue) { webservicesbasis.ID_Basis = BasisID.Value; } if (ID_Permission.HasValue) { webservicesbasis.ID_Permission = ID_Permission.Value; } if (CreatedOn.HasValue) { webservicesbasis.CreatedOn = Convert.ToDateTime((object)CreatedOn); } if (Active.HasValue) { webservicesbasis.Active = Convert.ToBoolean((object)Active); } classes1DataContext.SubmitChanges(); }