Esempio n. 1
0
        public override SaveResult <Student> Update(Student entity)
        {
            var existingStudent = Find(entity.Id);

            var previousDni = existingStudent.Dni;

            var output = base.Update(entity);


            if (output.IsSuccess)
            {
                output.Entity = entity;  //meu
                if (previousDni != output.Entity.Dni)
                {
                    StudentsByDni.Remove(previousDni);
                    StudentsByDni.Add(output.Entity.Dni, output.Entity);
                }
                else
                {
                    StudentsByDni[output.Entity.Dni] = output.Entity;
                }
            }

            return(output);
        }
Esempio n. 2
0
        public override SaveResult <Student> Add(Student entity)
        {
            var output = new SaveResult <Student>();                               // Meu

            output = base.Add(entity);                                             //JOSE
            if (entity.Id == QueryAll().FirstOrDefault(s => s.Id == entity.Id).Id) //MEU
            {
                output.Entity    = entity;
                output.IsSuccess = true;
            }

            if (output.IsSuccess || entity.Id == QueryAll().FirstOrDefault(s => s.Id == entity.Id).Id) //Meu
            {
                StudentsByDni.Add(output.Entity.Dni, output.Entity);                                   //de Jose
            }

            return(output);
        }