Ejemplo n.º 1
0
        /// <summary>
        /// 添加项目原料
        /// </summary>
        /// <param name="request"></param>
        public void AddMaterial(AddProjectMaterialRequest request)
        {
            Project model = this._projectRepository.FindBy(request.ProjectId);

            if (model == null)
            {
                throw new EntityIsInvalidException <string>(request.ProjectId.ToString());
            }
            Product product = this._productRepository.FindBy(request.ProductId);

            if (model == null)
            {
                throw new EntityIsInvalidException <string>(request.ProductId.ToString());
            }
            Users createUser = this._usersRepository.FindBy(request.CreateUserId);

            if (createUser == null)
            {
                throw new EntityIsInvalidException <string>(request.CreateUserId.ToString());
            }

            ProjectMaterial material = new ProjectMaterial(model, product, request.Qty, createUser);

            model.AddMaterial(material);

            this._projectRepository.Add(model);
            this._uow.Commit();
        }
        public void AddProjectMaterial(AddProjectMaterialRequest request)
        {
            ProjectMaterial model = this._projectMaterialRepository.FindBy(request.Id);

            if (model == null)
            {
                throw new EntityIsInvalidException <string>(request.Id.ToString());
            }
            this._projectMaterialRepository.Add(model);
            this._uow.Commit();
        }