Esempio n. 1
0
 /// <summary>
 /// Only use for new db entities
 /// </summary>
 /// <param name="dto"></param>
 /// <returns></returns>
 /// <exception cref="NotImplementedException"></exception>
 public static Change FromDAL(DALChangeDTO dto)
 {
     return(new Change()
     {
         OrganizationId = dto.OrganizationId,
         ChangeName = new MultiLangString(dto.Name),
     });
 }
Esempio n. 2
0
        /// <summary>
        ///  Maps Id, Name
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        /// <exception cref="NullReferenceException"></exception>
        public static BLLChangeDTO FromDAL3(DALChangeDTO dto)
        {
            if (dto == null)
            {
                throw new NullReferenceException("Can't map, DALChangeDTO is null");
            }

            return(new BLLChangeDTO()
            {
                Id = dto.Id,
                Name = dto.Name
            });
        }
Esempio n. 3
0
        /// <summary>
        /// Maps id, name, price, orgId
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        /// <exception cref="NullReferenceException"></exception>
        public static BLLChangeDTO FromDAL2(DALChangeDTO dto)
        {
            if (dto == null)
            {
                throw new NullReferenceException("Can't map, DALChangeDTO is null");
            }

            return(new BLLChangeDTO()
            {
                Id = dto.Id,
                Name = dto.Name,
                CurrentPrice = dto.CurrentPrice,
                OrganizationId = dto.OrganizationId
            });
        }
        public async Task <DALChangeDTO> AddAsync(DALChangeDTO changeDTO)
        {
            var change = ChangeMapper.FromDAL(changeDTO);

            change = (await RepoDbSet.AddAsync(change)).Entity;
            if (change == null)
            {
                return(null);
            }
            await RepoDbContext.Entry(change).Reference(c => c.ChangeName).LoadAsync();

            await RepoDbContext.Entry(change.ChangeName).Collection(c => c.Translations).LoadAsync();

            return(ChangeMapper.FromDomain(change));
        }
Esempio n. 5
0
        /// <summary>
        /// Maps id, name, price, orgId, CategoriesMin
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        /// <exception cref="NullReferenceException"></exception>
        public static BLLChangeDTO FromDAL(DALChangeDTO dto)
        {
            if (dto == null)
            {
                throw new NullReferenceException("Can't map, DALChangeDTO is null");
            }

            return(new BLLChangeDTO()
            {
                Id = dto.Id,
                Name = dto.Name,
                Categories = dto.Categories
                             .Select(CategoryMapper.FromDALToMin)
                             .ToList(),
                CurrentPrice = dto.CurrentPrice,
                OrganizationId = dto.OrganizationId
            });
        }
        public async Task <DALChangeDTO> EditAsync(DALChangeDTO changeDTO)
        {
            var change = await RepoDbSet.FindAsync(changeDTO.Id);

            if (change == null)
            {
                return(null);
            }

            await RepoDbContext.Entry(change).Reference(c => c.ChangeName).LoadAsync();

            await RepoDbContext.Entry(change.ChangeName).Collection(c => c.Translations).LoadAsync();


            change.ChangeName.SetTranslation(changeDTO.Name);

            return(ChangeMapper.FromDomain(change));
        }