Ejemplo n.º 1
0
 public static SingerModel ViewModelToModel(SingerViewModel viewModel)
 {
     return(new SingerModel()
     {
         Name = viewModel.Name, KindOfMusic = viewModel.KindOfMusic, Songs = viewModel.Songs
     });
 }
        public bool CreateSinger(SingerViewModel singer)
        {
            bool inserted;

            if (useMock)
            {
                singerDaoMock = new SingerDaoMock();
                inserted      = singerDaoMock.InsertSinger(SingerMapper.ViewModelToModel(singer));
            }
            else
            {
                singerDao = new SingerDao();
                inserted  = singerDao.InsertSinger(SingerMapper.ViewModelToModel(singer));
            }

            return(inserted);
        }
 public IHttpActionResult Post([FromBody] SingerViewModel singer)
 {
     try
     {
         if (singerBussines.CreateSinger(singer))
         {
             return(Ok());
         }
         else
         {
             return(NotFound());
         }
     }
     catch (Exception)
     {
         return(InternalServerError());
     }
 }
Ejemplo n.º 4
0
        private async void Page_Loaded(object sender, RoutedEventArgs e)
        {
            var singer = await Task.Factory.StartNew(() =>
            {
                return(_singerService.GetSingerById(_singerId));
            });

            if (singer != null)
            {
                _singerViewModel = new SingerViewModel()
                {
                    Id               = singer.Id,
                    Name             = singer.Name,
                    Nationality      = singer.Nationality,
                    ForeignerName    = singer.ForeignName,
                    ProfilePhotoPath = ConstantsUtil.DefaultSingerHeaderPath
                };
                DataContext = _singerViewModel;
                InitSingerInfoLabels();
            }
        }