Пример #1
0
        public RepositoryEntity Create(RepositoryEntity repositoryEntity)
        {
            Repositories repository = repositoryEntity.ToModel();

            smartDeliveryContext.Repositories.Add(repository);
            smartDeliveryContext.SaveChanges();
            return(new RepositoryEntity(repository));
        }
Пример #2
0
        public RepositoryEntity Update(Guid repositoryId, RepositoryEntity repositoryEntity)
        {
            Repositories repository = smartDeliveryContext.Repositories.Where(m => m.Id == repositoryId)
                                      .Include(u => u.Cabinet)
                                      .FirstOrDefault();

            if (repository == null)
            {
                throw new BadRequestException("Repository khong ton tai");
            }
            repositoryEntity.ToModel(repository);
            smartDeliveryContext.Repositories.Update(repository);
            smartDeliveryContext.SaveChanges();
            return(new RepositoryEntity(repository));
        }