public static void AddUnitate(List<string> unitati,Unitati item) { unitati.Add(item.numeUnitate); unitati.Add(item.descriere); unitati.Add(item.Contact.telefon); unitati.Add(item.Contact.email); }
/// <summary> /// Metoda care sterge o anumita unitate. /// </summary> /// <param name="unitate">unitatea pe care dorim sa o stergem</param> public static void DeleteUnitate(Unitati unitate) { try { using (MasterEntities context = new MasterEntities()) { var obj = context.Unitati.First(x => x.idUnitate == unitate.idUnitate); obj.isDeleted = true; context.ApplyCurrentValues("Unitati", obj); context.SaveChanges(); } } catch (Exception exc) { throw exc; } }
/// <summary> /// Metoda care updateaza o anumita unitate /// </summary> /// <param name="unitate">noua unitate</param> /// <param name="origUnitate">vechea unitate</param> public static void UpdateUnitate(Unitati unitate, Unitati origUnitate) { try { using (MasterEntities context = new MasterEntities()) { context.Unitati.Attach(origUnitate); context.ApplyCurrentValues("Unitati", unitate); context.SaveChanges(); } } catch (Exception exc) { throw exc; } }
/// <summary> /// Metoda care insereaza o noua unitate /// </summary> /// <param name="numeUnitate">numele unitatii</param> /// <param name="idLocalitate">id-ul localitatii</param> /// <param name="nrCamere">numarul de camere</param> /// <param name="descriere">descrierea unitatii</param> /// <param name="idTip">id-ul tipului unitatii</param> /// <param name="clasificare">clasificarea</param> /// <param name="idContact">id-ul contactului</param> /// <param name="path">pathul folderului cu imagini</param> /// <param name="idUtilizator">id admin</param> public static void InsertUnitate(string numeUnitate, int idLocalitate, int nrCamere, string descriere, int idTip, int clasificare, int idContact, string path, string numeUtilizator) { try { using (MasterEntities context = new MasterEntities()) { int idUtilizatorr = context.Utilizatori.First(i => i.numeUtilizator == numeUtilizator).idUtilizator; var r = new Unitati() { numeUnitate = numeUnitate, idContact = idContact, idLocalitate = idLocalitate, nrCamereDisp = nrCamere, descriere = descriere, idTip = idTip, clasificare = clasificare, pathImg = path, idUtilizator = idUtilizatorr, isDeleted = false, }; context.Unitati.AddObject(r); context.SaveChanges(); } } catch (Exception ex) { } }
/// <summary> /// Deprecated Method for adding a new object to the Unitati EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToUnitati(Unitati unitati) { base.AddObject("Unitati", unitati); }
/// <summary> /// Create a new Unitati object. /// </summary> /// <param name="idUnitate">Initial value of the idUnitate property.</param> /// <param name="idLocalitate">Initial value of the idLocalitate property.</param> /// <param name="nrCamereDisp">Initial value of the nrCamereDisp property.</param> /// <param name="idContact">Initial value of the idContact property.</param> /// <param name="descriere">Initial value of the descriere property.</param> /// <param name="idTip">Initial value of the idTip property.</param> /// <param name="idUtilizator">Initial value of the idUtilizator property.</param> /// <param name="pathImg">Initial value of the pathImg property.</param> /// <param name="clasificare">Initial value of the clasificare property.</param> /// <param name="numeUnitate">Initial value of the numeUnitate property.</param> public static Unitati CreateUnitati(global::System.Int32 idUnitate, global::System.Int32 idLocalitate, global::System.Int32 nrCamereDisp, global::System.Int32 idContact, global::System.String descriere, global::System.Int32 idTip, global::System.Int32 idUtilizator, global::System.String pathImg, global::System.Int32 clasificare, global::System.String numeUnitate) { Unitati unitati = new Unitati(); unitati.idUnitate = idUnitate; unitati.idLocalitate = idLocalitate; unitati.nrCamereDisp = nrCamereDisp; unitati.idContact = idContact; unitati.descriere = descriere; unitati.idTip = idTip; unitati.idUtilizator = idUtilizator; unitati.pathImg = pathImg; unitati.clasificare = clasificare; unitati.numeUnitate = numeUnitate; return unitati; }
/// <summary> /// Pentru fiecare unitate care va aprea in pagina creem un div in care vom adauga: /// - imaginea de profil a unitatii /// - numele unitatii /// - descrierea acesteia /// </summary> /// <param name="u"></param> private void GenerateDivForUnitate(Unitati u) { HtmlGenericControl divUnitate = new HtmlGenericControl("div"); Image img = new Image(); img.ImageUrl = u.pathImg + "/profil.jpg"; img.ImageAlign = ImageAlign.Left; img.Width = Unit.Pixel(124); img.Height = Unit.Pixel(95); LinkButton numeUnitate = new LinkButton(); numeUnitate.Text = u.numeUnitate; numeUnitate.Click += new EventHandler(numeUnitate_Click); numeUnitate.SkinID = "smth"; numeUnitate.Attributes.Add("style", "margin-left:5px"); Label descriere = new Label(); descriere.Text = u.descriere; descriere.Attributes.Add("style","margin-left:5px"); divUnitate.Controls.Add(new LiteralControl("<br />")); divUnitate.Controls.Add(img); divUnitate.Controls.Add(numeUnitate); divUnitate.Controls.Add(new LiteralControl("<br />")); divUnitate.Controls.Add(descriere); divUnitate.Controls.Add(new LiteralControl("<br />")); divUnitate.Controls.Add(new LiteralControl("<br />")); divUnitate.Controls.Add(new LiteralControl("<br />")); divUnitate.Controls.Add(new LiteralControl("<br />")); listaUnitati.Controls.Add(new LiteralControl("<br />")); listaUnitati.Controls.Add(divUnitate); }