Пример #1
0
        public void AddProject_WhenDataIsValid_ShouldSaveInDatabase()
        {
            using (new TransactionScope())
            {
                this.db.Users.Add(this.firstUser);
                this.db.Users.Add(this.secondUser);
                this.db.SaveChanges();

                var project = new ProjectCreateModel()
                {
                    Description = "Desc",
                    Name        = "Name",
                    Url         = "Url",
                    MembersIds  = new int[] { this.firstUser.Id, this.secondUser.Id }
                };

                var response = this.httpServer.CreatePostRequest(
                    "/api/projects/add?sessionKey=" + this.firstUser.SessionKey, project);
                Assert.AreEqual(HttpStatusCode.Created, response.StatusCode);

                var returnedModel = this.GetProjectFromResponse(response);
                Assert.IsNotNull(returnedModel);
                Assert.AreEqual("Name", returnedModel.Name);
                Assert.IsTrue(returnedModel.Id > 0);

                var projectEntity = this.db.Projects.GetById(returnedModel.Id);
                Assert.AreEqual(2, projectEntity.TeamMembers.Count);
            }
        }
Пример #2
0
        public async Task <String> createProject(string token, ProjectCreateModel project)
        {
            Uri uri = new Uri("http://projectservice.staging.tangentmicroservices.com:80/api/v1/projects/");

            try
            {
                client.DefaultRequestHeaders.TryAddWithoutValidation("Authorization", "Token " + token);
                var jsonProj    = new JavaScriptSerializer().Serialize(project);
                var httpContent = new StringContent(jsonProj, Encoding.UTF8, "application/json");

                var httpResponse = await client.PostAsync(uri, httpContent);

                if (httpResponse.Content != null)
                {
                    var responseContent = await httpResponse.Content.ReadAsStringAsync();

                    //var response = new JavaScriptSerializer().Deserialize<ProjectModel>(responseContent);
                    return(responseContent);
                }
                else
                {
                    throw new Exception("No response");
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Пример #3
0
        public async Task <IActionResult> CreateProject([FromForm] ProjectCreateModel model)
        {
            if (ModelState.IsValid == false)
            {
                return(View(model));
            }

            var session = await HttpContext.GetSession();

            if (session == null)
            {
                return(BadRequest());
            }

            model.CreatedByUserId = session.User.Id;

            var result = await projectRepo.Create(model);

            if (result == false)
            {
                this.AlertError("Could not persist this object.");
                return(View(model));
            }

            return(RedirectToAction(nameof(Index)));
        }
Пример #4
0
        public ActionResult Create(ProjectCreateModel model)
        {
            var managers = RolesManager.getSelectListByRole("manager");

            model.Managers = managers;

            if (ModelState.IsValid)
            {
                var manager = db.Users.Find(model.ManagerId);

                Project project = new Project
                {
                    Id          = model.Id,
                    Title       = model.Title,
                    Description = model.Description,
                    Customer    = model.Customer,
                    ManagerId   = manager.Id,
                    Manager     = manager
                };
                db.Projects.Add(project);
                db.SaveChanges();
                return(RedirectToAction("Details", new { id = project.Id }));
            }

            return(View(model));
        }
Пример #5
0
        public IActionResult Post([FromBody] ProjectCreateModel model)
        {
            var command = new CreateProjectCommand(model.Title, model.Description, new Guid(User.GetClaim("id")));

            _bus.PublishCommand(command);
            return(Ok());
        }
Пример #6
0
        public ActionResult Create(ProjectCreateModel model)
        {
            int customerid = Convert.ToInt32(model.CustomerUserName);
            var customer   = db.Customers.Find(customerid);

            var x = (model.End - model.Start).TotalDays;
            int y = int.Parse(x.ToString());

            if (model.End != null || model.Start != null)
            {
            }
            var project = new Project()
            {
                CustomerUserName = customer.UserName,
                Description      = model.Description,
                End               = model.End,
                Title             = model.Title,
                Start             = model.Start,
                StateName         = model.ProjectState.GetProjectStateName(),
                Sorumluenumolacak = model.Sorumluenumolacak,
                CustomerId        = customer.Id,
                TimeControl       = y,
            };

            db.Projects.Add(project);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #7
0
        public DefaultApiResponse ImportProject(ProjectCreateModel project, string token, out BusinessRulesApiResponse businessRulesApiResponse)
        {
            var _data = JsonConvert.SerializeObject(project, Newtonsoft.Json.Formatting.None,
                                                    new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            });
            var _address = ApiHelper.Instance.SiteUrl + ApiHelper.Instance.ProjectCreateEndpoint;

            businessRulesApiResponse = null;

            try
            {
                var _jsonResult = ApiHelper.Instance.WebClient(token).UploadString(_address, "POST", _data);

                if (_jsonResult != "null")
                {
                    return(new DefaultApiResponse(200, "OK", new string[] { }));
                }

                return(new DefaultApiResponse(500, "Internal Application Error: Fail to Import Project", new string[] { }));
            }
            catch (WebException _webEx)
            {
                using StreamReader _r = new StreamReader(_webEx.Response.GetResponseStream());
                string _responseContent = _r.ReadToEnd();

                return(ApiHelper.Instance.ProcessApiResponseContent(_webEx, _responseContent, out businessRulesApiResponse));
            }
        }
Пример #8
0
        public async Task <IActionResult> CreateProject(ProjectCreateModel model)
        {
            var result = await _projectService.CreateProject(model);

            await this._hubContext.Clients.All.SendAsync("newProject", result);

            return(Ok(result));
        }
 public async Task Create(ProjectCreateModel model)
 {
     using (var uow = _unitOfWorkFactory.Create())
     {
         var Project = Mapper.Map <Project>(model);
         await uow.Projects.CreateAsync(Project);
     }
 }
Пример #10
0
        public static ProjectCreateModel GetOrganizationOneProjectOneCreateModel()
        {
            var model = new ProjectCreateModel();

            model.OrganizationUid = OrganizationOneUid;
            model.Name            = OrganizationOneProjectOneName;
            model.Url             = HttpsUrl;

            return(model);
        }
Пример #11
0
        //
        // GET: /Project/Create
        public ActionResult Create()
        {
            var managers             = RolesManager.getSelectListByRole("manager");
            ProjectCreateModel model = new ProjectCreateModel
            {
                Managers = managers
            };

            return(View(model));
        }
Пример #12
0
        public IActionResult Upload(ProjectCreateModel file)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(file));
            }
            var id = this.projectService.Add(this.userManager.GetUserId(this.User), file.File, file.Title);

            return(this.RedirectToAction("Details", new { id }));
        }
Пример #13
0
        public static ProjectCreateModel MapProjectCreateModel(Guid organizationUid)
        {
            var model = new ProjectCreateModel();

            model.OrganizationUid = organizationUid;

            model.SetInputModelValues();

            return(model);
        }
Пример #14
0
 public async Task <String> CreateProject(ProjectCreateModel project)
 {
     try
     {
         return(await client.createProject((string)Session["token"], project));
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Пример #15
0
        public async Task CreateProjectAsync(ProjectCreateModel projectCreateModel, ClaimsPrincipal user)
        {
            using (var _uow = _unitOfWorkFactory.Create())
            {
                var Project = Mapper.Map <Project>(projectCreateModel);
                var User    = await _userManager.GetUserAsync(user);

                Project.UserId = User.Id;
                _uow._Projects.Create(Project);
            }
        }
Пример #16
0
        public async Task <IActionResult> ProjectCreate(ProjectCreateModel pCM)
        {
            if (ModelState.IsValid)
            {
                var fileName = Path.Combine(hostingEnvironment.WebRootPath + "/images", Path.GetFileName(pCM.FormFile.FileName));
                pCM.FormFile.CopyTo(new FileStream(fileName, FileMode.Create));

                var newProjekt = new Projekt()
                {
                    Nazwa   = pCM.projekt.Nazwa,
                    Logo    = "images/" + Path.GetFileName(pCM.FormFile.FileName),
                    IdFirma = pCM.projekt.IdFirma
                };

                _s16693context.Add(newProjekt);
                await _s16693context.SaveChangesAsync();

                var newZP = new ZespolProjekt()
                {
                    IdProjekt = newProjekt.IdProjekt,
                    IdZespol  = (int)pCM.zespol.IdZespol,
                    DataPrzypisaniaZespolu = DateTime.Now
                };

                var newPP = new ProjektPakiet()
                {
                    IdProjekt = newProjekt.IdProjekt,
                    IdPakiet  = (int)pCM.pakiet.IdPakiet,
                    DataRozpoczeciaWspolpracy = DateTime.Now
                };

                _s16693context.Add(newZP);
                _s16693context.Add(newPP);

                await _s16693context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            else if (!ModelState.IsValid)
            {
                var firma  = from e in _s16693context.Firma select e;
                var zespol = from e in _s16693context.Zespol select e;
                var pakiet = from e in _s16693context.Pakiet select e;

                pCM.zespols = await zespol.ToListAsync();

                pCM.pakiets = await pakiet.ToListAsync();

                pCM.firmas = await firma.ToListAsync();

                return(View("ProjectCreate", pCM));
            }
            return(View(pCM));
        }
Пример #17
0
        public ActionResult Create()
        {
            ProjectCreateModel model = new ProjectCreateModel()
            {
                Start     = DateTime.Now,
                End       = DateTime.Now,
                customers = db.Customers.ToList(),
            };

            return(View(model));
        }
Пример #18
0
        public async Task Create_POST_InvalidModel()
        {
            // arrange
            var model = new ProjectCreateModel();

            // act
            var result = await SystemUnderTest.Create(model);

            // assert
            AssertInputErrorMessagesOfView(result, model);
        }
Пример #19
0
        public async Task <ProjectModel> CreateProject(ProjectCreateModel model)
        {
            var entity  = _mapper.Map <tblProject>(model);
            var project = await _unitOfWork.ProjectRepository.Add(entity);

            await _unitOfWork.Commit();

            var result = _mapper.Map <ProjectModel>(project);

            return(result);
        }
Пример #20
0
        public ActionResult Create(int?type_ID, int?subType_ID, bool inMailingListOnly)
        {
            var model = new ProjectCreateModel();

            model.filter = new EventsFilterViewModel_ForList
            {
                Type_ID           = type_ID,
                SubType_ID        = subType_ID,
                InMailingListOnly = inMailingListOnly
            };
            return(View(model));
        }
Пример #21
0
 public IActionResult Create([FromBody] ProjectCreateModel model)
 {
     try
     {
         _projectService.Create(model);
         return(Ok());
     }
     catch (AppException ex)
     {
         return(BadRequest(new { message = ex.Message }));
     }
 }
Пример #22
0
 public Project ToEntity(ProjectCreateModel m)
 {
     return(new Project
     {
         Name = m.Name,
         BranchName = m.BranchName,
         RepositoryType = m.RepositoryType,
         RepositoryUrl = m.RepositoryUrl,
         CreatedAtUtc = DateTime.UtcNow,
         CreatedByUserId = m.CreatedByUserId,
     });
 }
Пример #23
0
        public async Task <IActionResult> Post(ProjectCreateModel model)
        {
            if (model == null)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, new Response {
                    Status = StatusEnum.Error, Message = "Project already exists!"
                }));
            }

            await ProjectService.Create(model);

            return(Ok());
        }
Пример #24
0
 public ActionResult Create(ProjectCreateModel model)
 {
     try
     {
         ProjectOperations.CreateUpdate(model.details, null, "", false);
         return(RedirectToAction("Index", new { Type_ID = model.filter.Type_ID, SubType_ID = model.filter.SubType_ID, InMailingListOnly = model.filter.InMailingListOnly }));
     }
     catch (Exception ex)
     {
         ModelState.AddModelError("", ex.Message);
         return(View(model));
     }
 }
Пример #25
0
        public async Task <IActionResult> Create(ProjectCreateModel model)
        {
            if (!model.Validate())
            {
                return(View(model));
            }

            //todo: map request and post

            var uid = "";

            return(RedirectToAction("Detail", "Project", uid));

            return(View());
        }
Пример #26
0
        public async Task <IActionResult> ProjectCreate()
        {
            var firma  = from e in _s16693context.Firma select e;
            var zespol = from e in _s16693context.Zespol select e;
            var pakiet = from e in _s16693context.Pakiet select e;

            var pCM = new ProjectCreateModel
            {
                firmas  = await firma.ToListAsync(),
                zespols = await zespol.ToListAsync(),
                pakiets = await pakiet.ToListAsync()
            };

            return(View(pCM));
        }
        public async Task <IActionResult> AddProject(ProjectCreateModel model)
        {
            var map = _mapper.Map <CreateProjectCommand>(model);

            var response = await _mediator.Send(map);

            if (response.Errors != null)
            {
                return(Create(response.Errors));
            }
            else
            {
                return(RedirectToAction("Index", "Project"));
            }
        }
Пример #28
0
        public ResponseMessage Create([FromBody] ProjectCreateModel model)
        {
            var result = _ProjectManage.Create(new Dao.Models.Project()
            {
                Name       = model.Name,
                CreateTime = DateTimeUtility.GetTimeMilliseconds(DateTime.Now),
                IsDelete   = 0,
                UserID     = _TenantManage.user.ID
            });

            if (result)
            {
                return(new ResponseMessage(MessageResult.Success, ""));
            }
            return(new ResponseMessage(MessageResult.Error, "创建项目失败"));
        }
Пример #29
0
        public HttpResponseMessage AddProject(
            [FromBody] ProjectCreateModel model, [FromUri] string sessionKey)
        {
            var responseMsg = this.PerformOperationAndHandleExceptions(() =>
            {
                this.ValidateProjectName(model.Name);
                this.ValidateProjectDescription(model.Description);
                this.ValidateProjectUrl(model.Url);

                var user    = this.GetUserBySessionKey(sessionKey);
                var project = new Project()
                {
                    Description = model.Description,
                    Name        = model.Name,
                    Url         = model.Url
                };

                project.TeamMembers.Add(user);
                foreach (int userId in model.MembersIds)
                {
                    var member = this.db.Users.GetById(userId);
                    if (member == null)
                    {
                        throw new ArgumentException(
                            string.Format("A user with id={0} does not exist", userId));
                    }

                    project.TeamMembers.Add(member);
                }

                this.db.Projects.Add(project);
                this.db.SaveChanges();

                var returnData = new ProjectModel()
                {
                    Id   = project.Id,
                    Name = project.Name
                };

                var response = this.Request.CreateResponse(HttpStatusCode.Created, returnData);
                return(response);
            });

            return(responseMsg);
        }
Пример #30
0
        public ActionResult Create()
        {
            var createModel = new ProjectCreateModel();

            try
            {
                createModel.ProjectCategorys = CommonHelpers.GetListProjectCatefory();
                createModel.Companys         = CommonHelpers.GetListCompany();
            }
            catch (Exception ex)
            {
                this.AddNotification(NotifSettings.Error_SystemBusy, NotificationType.ERROR);

                logger.Error("Failed display Create Project page: " + ex.ToString());
            }

            return(View(createModel));
        }