public Manager.Model.Poza[] GetByProdusId(Guid id) { Poza[] poza1; poza1 = databaseContext.Poza.Where(existingPoza => existingPoza.IdProdus == id).ToArray(); Manager.Model.Poza[] poza = new Manager.Model.Poza[poza1.Length]; if (poza != null) { for (int i = 0; i < poza1.Length; i++) { poza[i] = new Manager.Model.Poza { Id = poza1[i].Id.ToString(), CalePoza = poza1[i].CalePoza, IdProdus = poza1[i].IdProdus.ToString(), IsProduct = poza1[i].IsProduct }; } return(poza); } else { return(null); } }
public void Save(Manager.Model.Poza poza1) { Poza poza = new Poza(); if (poza1 != null) { poza.Id = Guid.NewGuid(); poza.IdProdus = Guid.Parse(poza1.IdProdus); poza.CalePoza = poza1.CalePoza; poza.IsProduct = poza1.IsProduct; databaseContext.Poza.Add(poza); databaseContext.SaveChanges(); } }
public Manager.Model.Poza[] PozaFaraProdus() { Poza[] poza1; poza1 = databaseContext.Poza.Where(existingPoza => existingPoza.IsProduct == false).ToArray(); Manager.Model.Poza[] poza = new Manager.Model.Poza[poza1.Length]; for (int i = 0; i < poza1.Length; i++) { poza[i] = new Manager.Model.Poza(); poza[i].Id = poza1[i].Id.ToString(); poza[i].CalePoza = poza1[i].CalePoza; poza[i].IdProdus = poza1[i].IdProdus.ToString(); poza[i].IsProduct = poza1[i].IsProduct; } return(poza); }
public Infrastructure.ValidationError[] Update(Manager.Model.Poza poza) { List <Infrastructure.ValidationError> errors = new List <Infrastructure.ValidationError>(); if (poza != null) { if (string.IsNullOrWhiteSpace(poza.IdProdus)) { errors.Add(new Infrastructure.ValidationError { Message = "Completeaza campul IdProdus!" }); } if (string.IsNullOrWhiteSpace(poza.Id)) { errors.Add(new Infrastructure.ValidationError { Message = "Completeaza campul Id!" }); } if (string.IsNullOrWhiteSpace(poza.CalePoza)) { errors.Add(new Infrastructure.ValidationError { Message = "Completeaza campul CalePoza!" }); } if (string.IsNullOrWhiteSpace(poza.CalePoza)) { errors.Add(new Infrastructure.ValidationError { Message = "Completeaza campul CalePoza!" }); } } else { errors.Add(new Infrastructure.ValidationError { Message = "Obiectul trimis este null!" }); } return(errors.ToArray()); }
public Manager.Model.Poza GetById(Guid id) { Manager.Model.Poza poza = new Manager.Model.Poza(); Poza poza1; poza1 = databaseContext.Poza.FirstOrDefault(existingPoza => existingPoza.Id == id); if (poza1 != null) { poza.Id = poza1.Id.ToString(); poza.CalePoza = poza1.CalePoza; poza.IdProdus = poza1.IdProdus.ToString(); poza.IsProduct = poza1.IsProduct; return(poza); } else { return(null); } }
public void Update(Manager.Model.Poza poza1) { Poza poza = new Poza(); Poza check; if (poza1 != null) { poza.Id = Guid.Parse(poza1.Id); poza.IdProdus = Guid.Parse(poza1.IdProdus); poza.CalePoza = poza1.CalePoza; poza.IsProduct = poza1.IsProduct; check = databaseContext.Poza.FirstOrDefault(existingPoza => existingPoza.Id == Guid.Parse(poza1.Id)); if (check != null) { databaseContext.Poza.Remove(check); databaseContext.Poza.Add(poza); databaseContext.SaveChanges(); } } }
public Infrastructure.ValidationError[] Save(Manager.Model.Poza poza) { List <Infrastructure.ValidationError> errors = new List <Infrastructure.ValidationError>(); if (poza != null) { if (poza.Files == null) { errors.Add(new Infrastructure.ValidationError { Message = "Adauga pozele!" }); } } else { errors.Add(new Infrastructure.ValidationError { Message = "Obiectul este null!" }); } return(errors.ToArray()); }