public ActionResult SaveAuthor(ViewModels.Author author) { var service = ResolveService <IAuthorService>(); var saveAuthor = service.GetByID(author.ID); saveAuthor = author.CopyToDomainModel(saveAuthor); service.SaveAuthor(saveAuthor); return(Json(new JsonResultData { Success = true })); }
public static ViewModels.Author CopyToViewModel(this DomainModels.Author domainModel, ViewModels.Author viewModel = null) { if (viewModel == null) { viewModel = new ViewModels.Author(); } viewModel.ID = domainModel.ID; viewModel.Name = domainModel.Name; viewModel.Introduction = domainModel.Introduction; return(viewModel); }
public static DomainModels.Author CopyToDomainModel(this ViewModels.Author viewModel, DomainModels.Author domainModel = null) { if (domainModel == null) { domainModel = new DomainModels.Author(); } domainModel.ID = viewModel.ID; domainModel.Name = viewModel.Name; domainModel.Introduction = viewModel.Introduction; domainModel.State = viewModel._state.Equals("added", StringComparison.CurrentCultureIgnoreCase) ? DomainModels.EntityState.Add : viewModel._state.Equals("modified", StringComparison.CurrentCultureIgnoreCase) ? DomainModels.EntityState.Modify : DomainModels.EntityState.Delete; return(domainModel); }