Пример #1
0
        public static TaskViewModel ToViewModel(this Task model)
        {
            var viewModel = new TaskViewModel();
            viewModel.InjectFrom(model);

            return viewModel;
        }
Пример #2
0
        public ActionResult AddTask(TaskViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var typeOftask = this._typeOfTaskManager.GetByName(viewModel.TypeName);
                if (typeOftask == null)
                {
                    typeOftask = new TypeOfTask()
                        {
                            Name = viewModel.TypeName
                        };

                    this._typeOfTaskManager.Add(typeOftask);
                }
                var task = viewModel.ToModel();
                task.TypeID = typeOftask.Id;
                this._taskManager.Add(task);
            }

            return this.Json(new {success = false});
        }