Ejemplo n.º 1
0
        public OperationResult ChangeEmployeeWithProfile(Profile profile)
        {
            var profileFromBdResult = profileHandler.Get(profile.Id);

            if (!profileFromBdResult.Ok)
            {
                return(OperationResult.BuildFromOperationResult(profileFromBdResult));
            }
            dbContext.Entry(profileFromBdResult.ResultModel).CurrentValues.SetValues(profile);
            profileFromBdResult.ResultModel.Employee = profile.Employee;

            var attachResult = AttachEmployeerIfNeeded(profileFromBdResult.ResultModel);

            if (!attachResult.Ok)
            {
                return(attachResult);
            }

            dbContext.Update(profileFromBdResult.ResultModel);
            dbContext.SaveChanges();
            return(OperationResult.BuildSuccess());
        }
Ejemplo n.º 2
0
        public OperationResult Change(TKey key, T newValue)
        {
            var valueFromBd = dbContext.Find <T>(key);

            if (valueFromBd == null)
            {
                return(OperationResult.BuildNotFoundError(typeName + " с таким id не найден"));
            }

            //var verificationResult =            //if (!verificationResult.Ok)
            //    return verificationResult;

            dbContext.Entry(valueFromBd).CurrentValues.SetValues(newValue);
            dbContext.SaveChanges();
            return(OperationResult.BuildSuccess());
        }