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> Delete(Student entity)    //MEU
        {
            var output = new SaveResult <Student>();

            output = base.Delete(entity);

            if (output.IsSuccess)
            {
                output.Entity = entity;
                StudentsByDni.Remove(output.Entity.Dni);
                output.IsSuccess = true;
            }
            else
            {
                output.IsSuccess = false;
            }

            return(output);
        }