예제 #1
0
        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);
            }
        }
예제 #2
0
        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();
            }
        }
예제 #3
0
        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);
        }
예제 #4
0
        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());
        }
예제 #5
0
        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);
            }
        }
예제 #6
0
        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();
                }
            }
        }
예제 #7
0
        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());
        }