public static UseFullCategory Map(UseFullCategory modelToUpdate, UseFullUpdatePostInputDtoModel dtoModel) { modelToUpdate.ImageAddress = dtoModel.ImageAddress; modelToUpdate.Name = dtoModel.UseFullCategoryName; return(modelToUpdate); }
public async Task CreateUseFullCategoryByNameAsync(string name, string imageAddress) { var towns = this.towns.All(); if (imageAddress == null) { imageAddress = GlobalConstants.ImageAddress; } UseFullCategory useFullCategory = new UseFullCategory() { Name = name, ImageAddress = imageAddress, }; foreach (var town in towns) { TownUseFullCategory townUseFullCategory = new TownUseFullCategory() { UseFullCategory = useFullCategory, Town = town, }; await this.townUseFullCategories.AddAsync(townUseFullCategory); } await this.useFullCategories.AddAsync(useFullCategory); await this.useFullCategories.SaveChangesAsync(); }
public static UseFullUpdateGetOutputDtoModel Map(UseFullCategory model) { var dtoOutputModel = new UseFullUpdateGetOutputDtoModel { UseFullCategoryId = model.Id, UseFullCategoryName = model.Name, ImageAddress = model.ImageAddress }; return(dtoOutputModel); }
public static Company Map(CompanyInputViewDtoModel company, Town town, UseFullCategory useFullCategory) { var currentCompany = new Company() { Name = company.Name, Town = town, Address = company.Address, Phone = company.Phone, UseFullCategory = useFullCategory, }; return(currentCompany); }
public static Company Map(Company companyForCange, CompanyUpdateInputDtoModel dtoModel, Town neededTown, UseFullCategory neededCategory) { companyForCange.Name = dtoModel.CompanyName; companyForCange.Town = neededTown; companyForCange.Address = dtoModel.Address; companyForCange.Phone = dtoModel.Phone; companyForCange.UseFullCategory = neededCategory; return(companyForCange); }
public async Task CreateCompanyAsync(CompanyInputViewModel company) { UseFullCategory useFullCategory = await this.useFullCategories.All() .FirstOrDefaultAsync(x => x.Name == company.CategoryName); Town town = await this.towns.All().FirstOrDefaultAsync(x => x.Name == company.TownName); Company currentCompany = new Company() { Name = company.Name, Town = town, Address = company.Address, Phone = company.Phone, UseFullCategory = useFullCategory, }; await this.conpanies.AddAsync(currentCompany); await this.conpanies.SaveChangesAsync(); }