Custom vs User control

Choice is not only between user control and custom control, but among user control, custom control, customizing control template, customizing data template, header template (for collection based controls), attached properties. Refer to Control Authoring overview I go by following order of consideration Attached Properties : If functionality can be achieved, I use attached properties. Example, … Read more

How to map View Model back to Domain Model in a POST action?

I use an IBuilder interface and implement it using the ValueInjecter public interface IBuilder<TEntity, TViewModel> { TEntity BuildEntity(TViewModel viewModel); TViewModel BuildViewModel(TEntity entity); TViewModel RebuildViewModel(TViewModel viewModel); } … (implementation) RebuildViewModel just calls BuildViewModel(BuilEntity(viewModel)) [HttpPost] public ActionResult Update(ViewModel model) { if(!ModelState.IsValid) { return View(builder.RebuildViewModel(model); } service.SaveOrUpdate(builder.BuildEntity(model)); return RedirectToAction(“Index”); } btw I don’t write ViewModel I write Input … Read more

Why a viewmodel factory is needed in Android?

We can not create ViewModel on our own. We need ViewModelProviders utility provided by Android to create ViewModels. But ViewModelProviders can only instantiate ViewModels with no arg constructor. So if I have a ViewModel with multiple arguments, then I need to use a Factory that I can pass to ViewModelProviders to use when an instance … Read more

How to update LiveData of a ViewModel from background service and Update UI

I am assuming that you are using android architecture components. Actually it doesn’t matter wherever you are calling service, asynctask or handler to update the data. You can insert the data from the service or from the asynctask using postValue(..) method. Your class would look like this: private void loadUsers() { // do async operation … Read more

what is difference between a Model and an Entity

The definition of these terms is quite ambiguous. You will find different definitions at different places. Entity: An entity represents a single instance of your domain object saved into the database as a record. It has some attributes that we represent as columns in our tables. Model: A model typically represents a real world object … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)