public async Task <CustomerVM> AddCustomer([FromBody] ViewModels.CustomerManagement.CustomerVM model)
        {
            var customer = new Customer(model.Name);

            _unitOfWork.Customers.Add(customer);

            await _unitOfWork.CommitAsync();

            return(customer.ToModel());
        }
        public async Task <ProjectVM> AddProject([FromBody] ViewModels.ProjectManagement.ProjectVM model)
        {
            var customer = await _unitOfWork.Customers.GetAsync(model.CustomerId);

            var project = new Project(model.Title, customer);

            _unitOfWork.Projects.Add(project);

            await _unitOfWork.CommitAsync();

            return(project.ToModel());
        }
Beispiel #3
0
        public async Task TestMethod1()
        {
            IWindsorContainer container = Container.Configure();

            UZTask createdTask;

            using (TaskContext taskContext = new TaskContext())
            {
                createdTask       = new UZTask();
                createdTask.Id    = Guid.NewGuid();
                createdTask.Title = "Test title";

                taskContext.Tasks.Add(createdTask);

                await taskContext.SaveChangesAsync();
            }

            using (IDomainUnitOfWork <Guid, UZTask, IRepository <Guid, UZTask> > unitOfWork = container.Resolve <IDomainUnitOfWork <Guid, UZTask, IRepository <Guid, UZTask> > >())
            {
                var task = await unitOfWork.Repository.GetByIdAsync(createdTask.Id);


                task.Object.Title = "Changed title";

                await unitOfWork.CommitAsync();
            }

            using (TaskContext taskContext = new TaskContext())
            {
                taskContext.Database.Log = t => Debug.WriteLine(t);

                List <string> items = new List <string> {
                    "Changed title"
                };
                IQueryable <UZTask> tasks = taskContext.Tasks.Where(t => items.Contains(t.Title));



                /* UZTask task1 = tasks.First();
                 * task1.Title = "Change title 2";*/

                await taskContext.SaveChangesAsync();
            }
        }