Example #1
0
        public Task <BaseResponse> Put(int id, [FromBody] MobileViewModel model)
        {
            MobileListItem updateModel = new MobileListItem
            {
                Brand            = model.Brand,
                CPU              = model.CPU,
                InternalMemory   = model.InternalMemory,
                Name             = model.Name,
                OS               = model.OS,
                Price            = model.Price,
                RAM              = model.RAM,
                ScreenResolution = model.ScreenResolution,
                ScreenSize       = model.ScreenSize,
                Size             = model.Size,
                VideoUrl         = model.VideoUrl,
                Weight           = model.Weight
            };

            foreach (var item in model.Photos)
            {
                Domain.DTO.ServiceModels.Photo photo = new Domain.DTO.ServiceModels.Photo
                {
                    Base64  = item.Base64,
                    PhotoId = item.PhotoId
                };
                updateModel.Photos.Add(photo);
            }

            return(_mobileService.UpdateMobile(updateModel));
        }
Example #2
0
        public async Task <BaseResponse> Post([FromBody] MobileViewModel model)
        {
            InsertMobileModel insertModel = new InsertMobileModel
            {
                Brand            = model.Brand,
                CPU              = model.CPU,
                InternalMemory   = model.InternalMemory,
                Name             = model.Name,
                OS               = model.OS,
                Price            = model.Price,
                RAM              = model.RAM,
                ScreenResolution = model.ScreenResolution,
                ScreenSize       = model.ScreenSize,
                Size             = model.Size,
                VideoUrl         = model.VideoUrl,
                Weight           = model.Weight
            };

            foreach (var item in model.Photos)
            {
                Domain.DTO.ServiceModels.Photo photo = new Domain.DTO.ServiceModels.Photo
                {
                    Base64  = item.Base64,
                    PhotoId = item.PhotoId
                };
                insertModel.Photos.Add(photo);
            }

            return(await _mobileService.InsertMobile(insertModel));
        }