コード例 #1
0
        public Infrastructure.ValidationError[] Update(Manager.Model.Produs produs)
        {
            Guid guid = new Guid();

            List <Infrastructure.ValidationError> errors = new List <Infrastructure.ValidationError>();

            if (produs != null)
            {
                if (string.IsNullOrWhiteSpace(produs.Culoare))
                {
                    errors.Add(new Infrastructure.ValidationError {
                        Message = "Completeaza campul Culoare!"
                    });
                }

                if (string.IsNullOrWhiteSpace(produs.Titlu))
                {
                    errors.Add(new Infrastructure.ValidationError {
                        Message = "Completeaza campul Titlu!"
                    });
                }

                if (string.IsNullOrWhiteSpace(produs.Marime))
                {
                    errors.Add(new Infrastructure.ValidationError {
                        Message = "Completeaza campul Marime!"
                    });
                }

                if (string.IsNullOrWhiteSpace(produs.Id))
                {
                    errors.Add(new Infrastructure.ValidationError {
                        Message = "Completeaza campul Id!"
                    });
                }

                if (string.IsNullOrWhiteSpace(produs.Categorie))
                {
                    errors.Add(new Infrastructure.ValidationError {
                        Message = "Completeaza campul Categorie!"
                    });
                }

                if (produs.Pret == 0)
                {
                    errors.Add(new Infrastructure.ValidationError {
                        Message = "Completeaza campul Pret!"
                    });
                }

                Guid.TryParse(produs.Id, out guid);
                if (guid != Guid.Empty)
                {
                    if (produsResource.GetById(guid) == null)
                    {
                        errors.Add(new Infrastructure.ValidationError {
                            Message = "Produsul nu exista in baza de date!"
                        });
                    }
                }
            }
            else
            {
                errors.Add(new Infrastructure.ValidationError {
                    Message = "Obiectul este null!"
                });
            }

            return(errors.ToArray());
        }
コード例 #2
0
 public Model.Produs GetById(Guid id)
 {
     return(produsResource.GetById(id));
 }