// GET: api/Labels
        public LabelDTO[] GetLabels(String date)
        {
            //var user = Membership.GetUser(User.Identity.Name);
            DateTimeOffset date2 = DateTimeOffset.Parse(date);
            string         id    = User.Identity.GetUserId();

            Label[] entityArray = (from b in db.Labels
                                   where (b.ApplicationUserId == id /*&& b.LastMod.UtcTicks / 10000 * 10000 > date2.UtcTicks*/)
                                   select b).ToArray();

            // Label[] entityArray = tasks.ToArray();

            LabelDTO[] listItemList = new LabelDTO[entityArray.Count()];
            for (int i = 0; i < entityArray.Count(); i++)
            {
                listItemList[i] = new LabelDTO(entityArray[i]);
            }

            return(listItemList);

            //ContactDTO[] listItemList = new ContactDTO[tasks.Count()];
            //int i = 0;
            //foreach (Contact c in tasks)
            //{
            //    listItemList[i] = new ContactDTO(tasks.g[i]);
            //    i++;
            //}

            //return listItemList;
        }
Exemplo n.º 2
0
        public LabelDTO CreateLabel(LabelDTO label)
        {
            try
            {
                var labelModel = new LabelModel
                {
                    Title = label.Title,
                    Color = label.Color
                };

                db_.GetCollection <LabelModel>("Labels").InsertOne(labelModel);
                ObjectId cardObjectId = new ObjectId(label.CardId);

                var filter = Builders <CardModel> .Filter.Eq(l => l.Id, cardObjectId);

                var update = Builders <CardModel> .Update.Push(c => c.Labels, labelModel.Id);

                db_.GetCollection <CardModel>("Cards").UpdateOne(filter, update);

                label.Id = labelModel.Id.ToString();
                return(label);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        // GET: api/Labels
        public LabelDTO[] GetLabels()
        {
            //var user = Membership.GetUser(User.Identity.Name);
            string id       = User.Identity.GetUserId();
            var    contacts = from b in db.Labels
                              where b.ApplicationUserId == id
                              select b;

            Label[] entityArray = contacts.ToArray();

            LabelDTO[] listItemList = new LabelDTO[entityArray.Count()];
            for (int i = 0; i < entityArray.Count(); i++)
            {
                listItemList[i] = new LabelDTO(entityArray[i]);
            }

            return(listItemList);

            //ContactDTO[] listItemList = new ContactDTO[tasks.Count()];
            //int i = 0;
            //foreach (Contact c in tasks)
            //{
            //    listItemList[i] = new ContactDTO(tasks.g[i]);
            //    i++;
            //}

            //return listItemList;
        }
        public IActionResult Get()
        {
            var pullrequestEvents = _pullRequestEventRepository.GetAll(null, null);

            var viewModel = new List<PullRequestEventViewModel>();

            var marked = new Marked();
            foreach (var pullRequestEvent in pullrequestEvents)
            {
                var itemViewModel = new PullRequestEventViewModel()
                {
                    Action = pullRequestEvent.Action,
                    Body = marked.Parse(pullRequestEvent.Body),
                    CreatedAt = pullRequestEvent.CreatedAt,
                    Merged = pullRequestEvent.Merged,
                    MergedAt = pullRequestEvent.MergedAt,
                    MergedBy = pullRequestEvent.MergedBy,
                    RepositoryName = pullRequestEvent.RepositoryName,
                    Title = pullRequestEvent.Title,
                    Id = pullRequestEvent.Id
                };

                //itemViewModel.Team = new Models.TeamResponse()
                //{
                //    Id = pullRequestEvent.Team.Id,
                //    Name = pullRequestEvent.Team.Name,
                //};

                //if(pullRequestEvent.Team.ChildrenTeams != null)
                //{   
                //    itemViewModel.Team.ChildrenTeam = new List<Models.TeamResponse>();
                //    foreach (var childTeam in pullRequestEvent.Team.ChildrenTeams)
                //    {
                //        var childTeamResponse = new Models.TeamResponse()
                //        {
                //            Id = childTeam.Id,
                //            Name = childTeam.Name
                //        };
                //        itemViewModel.Team.ChildrenTeam.Add(childTeamResponse);
                //    }
                //}

                itemViewModel.Labels = new List<LabelDTO>();
                foreach (var label in pullRequestEvent.Labels)
                {
                    var labelDTO = new LabelDTO()
                    {
                        Color = label.Color,
                        Name = label.Name
                    };

                    itemViewModel.Labels.Add(labelDTO);
                }

                viewModel.Add(itemViewModel);
            }

            return Ok(viewModel);
        }
Exemplo n.º 5
0
 public IActionResult Edit([FromForm] LabelDTO label)
 {
     if (ModelState.IsValid)
     {
         _labelService.Update(label, _userId);
     }
     return(RedirectToAction(nameof(List)));
 }
Exemplo n.º 6
0
        /// <summary>
        /// Adds the label.
        /// </summary>
        /// <param name="label">The label.</param>
        /// <returns></returns>
        public LabelDTO AddLabel(LabelDTO label)
        {
            LabelEntity labelEntity = _mapper.Map <LabelDTO, LabelEntity>(label);

            labelEntity.CreatedDate = DateTime.Now;
            _repo.Add(labelEntity);
            return(label);
        }
Exemplo n.º 7
0
        public IActionResult Create()
        {
            var label = new LabelDTO()
            {
                UserId = _userId
            };

            return(View(label));
        }
Exemplo n.º 8
0
        public IActionResult Create([FromForm] LabelDTO label)
        {
            if (ModelState.IsValid)
            {
                _labelService.Create(label);
            }

            return(RedirectToAction(nameof(List)));
        }
Exemplo n.º 9
0
        public async Task <IActionResult> CreateLabel(LabelDTO label)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("invalid input, object invalid"));
            }

            return(Ok((await _labelRepository.CreateLabel(label)).Base64));
        }
Exemplo n.º 10
0
 public async Task <IActionResult> Post([FromBody] LabelDTO model)
 {
     if (await labelService.Insert(model))
     {
         return(Ok());
     }
     else
     {
         return(BadRequest());
     }
 }
Exemplo n.º 11
0
        public async Task <ActionResult <Label> > PostLabel([FromBody] LabelDTO labelDTO)
        {
            if (labelDTO.Name == null)
            {
                return(BadRequest(new { message = "Label Name mandatory" }));
            }
            var label = _mapper.Map <LabelDTO, Label>(labelDTO);
            await _labelService.CreateLabel(label);

            return(CreatedAtAction("GetLabel", new { id = label.Id }, label));
        }
        public void AddLabel_InValidData()
        {
            LabelEntity labelEntity = null;
            LabelDTO    labelDTO    = null;

            _mapper.Setup(p => p.Map <LabelDTO, LabelEntity>(labelDTO)).Returns(labelEntity);
            _repo.Setup(p => p.Add(labelEntity)).Returns(0);
            var returnObj = labelService.AddLabel(labelDTO);

            Assert.IsTrue(returnObj == null);
        }
Exemplo n.º 13
0
        public void Create(LabelDTO label)
        {
            if (label == null)
            {
                throw new ArgumentNullException(nameof(label));
            }

            var labelEntity = _mapper.Map <LabelDTO, Label>(label);

            _repository.Create(labelEntity);
            _repository.SaveChanges();
        }
Exemplo n.º 14
0
        public ActionResult Post([FromBody] LabelDTO label)
        {
            try
            {
                var result = label_repo_.CreateLabel(label);

                return(this.Ok(result));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 15
0
        public LabelDTO CreateLabel(LabelDTO label)
        {
            var result = db_.CreateLabel(label);

            if (result != null)
            {
                return(result);
            }
            else
            {
                throw new Exception();
            }
        }
Exemplo n.º 16
0
        public ActionResult RemoveLabel(string id, [FromBody] LabelDTO label)
        {
            try
            {
                var result = card_repo_.RemoveLabel(id, label.Id);

                return(this.Ok(result));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public void AddLabel_ValidData()
        {
            var labelDto = new LabelDTO {
                Id = 11, Description = "Label_11", CreatedBy = 1, UpdatedBy = 1, CreatedDate = DateTime.Now, UpdatedDate = DateTime.Now
            };

            _labelService.Setup(p => p.AddLabel(labelDto)).Returns(labelDto);
            var returnObj   = labelController.AddLabel(labelDto);
            var okResult    = returnObj.Result as ObjectResult;
            var valueResult = okResult.Value as LabelDTO;

            Assert.AreEqual(11, valueResult.Id);
        }
Exemplo n.º 18
0
        public void Update(LabelDTO label, string _userId)
        {
            if (label == null)
            {
                throw new ArgumentNullException(nameof(label));
            }
            var res = GetById(label.Id, _userId); // will check access

            var labelEntity = _mapper.Map <LabelDTO, Label>(label);

            _repository.Update(labelEntity);
            _repository.SaveChanges();
        }
Exemplo n.º 19
0
        protected override void Context()
        {
            base.Context();
            _label   = "label";
            _comment = "Comment";
            var labelDTO = new LabelDTO {
                Label = _label, Comment = _comment
            };

            A.CallTo(() => _labelPresenter.CreateLabel()).Returns(true);
            A.CallTo(() => _labelPresenter.LabelDTO).Returns(labelDTO);
            A.CallTo(() => _historyManager.AddLabel(A <ILabelCommand> .Ignored))
            .Invokes(x => _command = x.Arguments.Get <ILabelCommand>(0));
        }
        public void AddLabel_ValidData()
        {
            var labelDto = new LabelDTO {
                Id = 11, Description = "Label_11", CreatedBy = 1, UpdatedBy = 1, CreatedDate = DateTime.Now, UpdatedDate = DateTime.Now
            };
            var labelEntity = new LabelEntity {
                Id = 11, Description = "Label_11", CreatedBy = 1, UpdatedBy = 1, CreatedDate = DateTime.Now, UpdatedDate = DateTime.Now
            };

            _mapper.Setup(p => p.Map <LabelDTO, LabelEntity>(labelDto)).Returns(labelEntity);
            _repo.Setup(p => p.Add(labelEntity)).Returns(1);
            var returnObj = labelService.AddLabel(labelDto);

            Assert.AreEqual(11, returnObj.Id);
        }
Exemplo n.º 21
0
        public async Task <bool> Insert(LabelDTO newLabel)
        {
            if (newLabel != null)
            {
                QuestionLabel labelToAdd = new QuestionLabel()
                {
                    LabelText = newLabel.LabelText,
                    Question  = await questionRepository.GetAsync(newLabel.QuestionID)
                };

                return(await questionRepository.AddLabelAsync(labelToAdd));
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 22
0
        public async Task <Label> CreateLabel(LabelDTO dto)
        {
            Label label = new Label
            {
                Sender    = dto.Sender.RetrieveAddress(),
                Receiver  = dto.Receiver.RetrieveAddress(),
                Features  = dto.Features.RetrieveFeatures(),
                Identcode = _identcodeGenerator.Call(),
            };

            label.Base64 = _labelGenerator.Generate(label);

            await _context.Labels.AddAsync(label).ConfigureAwait(true);

            await _context.SaveChangesAsync();

            return(label);
        }
Exemplo n.º 23
0
        /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
        /// <exception cref="ApiException">A server side error occurred.</exception>
        public async System.Threading.Tasks.Task <FileResponse> CreateLabelAsync(LabelDTO label, System.Threading.CancellationToken cancellationToken)
        {
            var urlBuilder_ = new System.Text.StringBuilder();

            urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/Label/label");

            var client_ = _httpClient;

            try
            {
                using (var request_ = new System.Net.Http.HttpRequestMessage())
                {
                    var content_ = new System.Net.Http.StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(label, _settings.Value));
                    content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json");
                    request_.Content             = content_;
                    request_.Method = new System.Net.Http.HttpMethod("POST");
                    request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/octet-stream"));

                    PrepareRequest(client_, request_, urlBuilder_);
                    var url_ = urlBuilder_.ToString();
                    request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);
                    PrepareRequest(client_, request_, url_);

                    var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);

                    try
                    {
                        var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value);
                        if (response_.Content != null && response_.Content.Headers != null)
                        {
                            foreach (var item_ in response_.Content.Headers)
                            {
                                headers_[item_.Key] = item_.Value;
                            }
                        }

                        ProcessResponse(client_, response_);

                        var status_ = ((int)response_.StatusCode).ToString();
                        if (status_ == "200" || status_ == "206")
                        {
                            var responseStream_ = response_.Content == null ? System.IO.Stream.Null : await response_.Content.ReadAsStreamAsync().ConfigureAwait(false);

                            var fileResponse_ = new FileResponse((int)response_.StatusCode, headers_, responseStream_, null, response_);
                            client_ = null; response_ = null; // response and client are disposed by FileResponse
                            return(fileResponse_);
                        }
                        else
                        if (status_ != "200" && status_ != "204")
                        {
                            var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);

                            throw new ApiException("The HTTP status code of the response was not expected (" + (int)response_.StatusCode + ").", (int)response_.StatusCode, responseData_, headers_, null);
                        }

                        return(default(FileResponse));
                    }
                    finally
                    {
                        if (response_ != null)
                        {
                            response_.Dispose();
                        }
                    }
                }
            }
            finally
            {
            }
        }
Exemplo n.º 24
0
 public void BindTo(LabelDTO labelDTO)
 {
     _screenBinder.BindToSource(labelDTO);
     SetOkButtonEnable();
 }
Exemplo n.º 25
0
 public ActionResult <LabelDTO> AddLabel(LabelDTO label)
 {
     _logger.Info(() => "Api AddLabel");
     _labelService.AddLabel(label);
     return(StatusCode((int)HttpStatusCode.OK, label));
 }
Exemplo n.º 26
0
        public async Task <Label> AddLabel(LabelDTO label)
        {
            var labelInput = _mapper.Map <LabelDTO, Label>(label);

            return(await _labelService.CreateLabel(labelInput));
        }
        public async Task <IHttpActionResult> PostLabel(LabelDTO label)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            // now the user is authenticated

            Label newEntity = null;

            if (label.ID != 0)
            {
                return(BadRequest(ModelState));
            }
            else
            {
                newEntity = new Label();
                db.Labels.Add(newEntity);
            }

            Label parentEntity = null;

            if (label.ParentID != 0)
            {
                parentEntity = db.Labels.Where(b => b.ID == label.ParentID).SingleOrDefault();

                if (parentEntity == null)
                {
                    //dbTransaction.Rollback();
                    //     return new SetEntityResponse(SetEntityResult.ParentEntityIsNotFound, null,/*"The requested parent remind was not found on the server",*/ entityDTO.ID, null, null, DateTime.UtcNow);
                    return(BadRequest(ModelState));
                }

                if (parentEntity.Deleted && !label.Deleted)
                {
                    //dbTransaction.Rollback();
                    return(BadRequest(ModelState));
                    //return new SetEntityResponse(SetEntityResult.ParentEntityIsDeleted, null,/*"The requested parent remind was deleted on the server",*/ entityDTO.ID, null, null, DateTime.UtcNow);
                }
            }

            // verify field consistency

            if (label.ID == 0 && label.Deleted)
            {
                // dbTransaction.Rollback();
                //return new SetEntityResponse(SetEntityResult.EntityHasIncorrectData, "entityDTO.ID == 0 && entityDTO.Deleted", 0, null, null, DateTime.UtcNow);
                return(BadRequest(ModelState));
            }

            //if (label.UserName == null || label.UserName.Equals(""))
            //{
            //    //      return new SetEntityResponse(SetEntityResult.EntityHasIncorrectData, "entityDTO.UserName == null || entityDTO.UserName.Equals(\"\")", 0, null, null, DateTime.UtcNow);
            //    return BadRequest(ModelState);
            //}

            // verify child parent relation consistency
            if (label.ID != 0 && label.ParentID != 0 && label.ID == label.ParentID)
            {
                //     dbTransaction.Rollback();
                //      return new SetEntityResponse(SetEntityResult.EntityHasIncorrectData, "Parent remind is set to the remind itself", 0, null, null, DateTime.UtcNow);
                return(BadRequest(ModelState));
            }

            newEntity.ID      = label.ID;
            newEntity.Created = label.Created;
            newEntity.Text    = label.Text;
            //newEntity.UserName = label.UserName;
            newEntity.Description = label.Description;
            newEntity.ParentID    = label.ParentID;
            newEntity.SortOrder   = label.SortOrder;
            newEntity.LastMod     = label.LastMod;
            newEntity.Deleted     = label.Deleted;
            newEntity.CompanyID   = label.CompanyID;
            //newEntity.OriginalID = entityDTO.OriginalID;
            newEntity.IsCompany = label.IsCompany;
            newEntity.IsSection = label.IsSection;

            //public virtual ICollection<Tasks> TaskList { get; set; }
            //public virtual ICollection<Contacts> ContactList { get; set; }
            //public virtual ICollection<Files> FileList { get; set; }
            //public virtual UserProfiles UserProfile { get; set; }
            //public virtual ICollection<Labels> ChildLabels { get; set; }
            //public virtual Labels ParentLabel { get; set; }

            newEntity.LastMod = DateTimeOffset.UtcNow;
            if (newEntity.ID == 0)
            {
                newEntity.Created = newEntity.LastMod;
            }

            //List<EntityData> NotFoundRelatedEntities = new List<EntityData>();
            //foreach (int entityId in entityDTO.Contacts)
            //{
            //    Contacts remind = db.Contacts.Where(b => b.ContactID == entityId && b.UserProfile.Username.Equals(entityDTO.UserName)).SingleOrDefault();
            //    if (remind != null)
            //    {
            //        newEntity.ContactList.Add(remind);
            //    }
            //    else
            //    {
            //        NotFoundRelatedEntities.Add(new EntityData(remind.ContactID, EntityType.Contact));
            //    }
            //}

            //foreach (int entityId in entityDTO.Tasks)
            //{
            //    Tasks remind = db.Tasks.Where(b => b.TaskID == entityId && b.UserProfile.Username.Equals(entityDTO.UserName)).SingleOrDefault();
            //    if (remind != null)
            //    {
            //        newEntity.TaskList.Add(remind);
            //    }
            //    else
            //    {
            //        NotFoundRelatedEntities.Add(new EntityData(remind.TaskID, EntityType.Simple));
            //    }
            //}

            //foreach (int entityId in entityDTO.Files)
            //{
            //    Files remind = db.Files.Where(b => b.FileID == entityId && b.UserProfile.Username.Equals(entityDTO.UserName)).SingleOrDefault();
            //    if (remind != null)
            //    {
            //        newEntity.FileList.Add(remind);
            //    }
            //    else
            //    {
            //        NotFoundRelatedEntities.Add(new EntityData(remind.FileID, EntityType.File));
            //    }
            //}

            // db.SaveChanges();

            //dbTransaction.Commit();
            //return new SetEntityResponse(SetEntityResult.Saved, null, newEntity.ID, newEntity.LastMod.UtcDateTime, NotFoundRelatedEntities.Count == 0 ? null : NotFoundRelatedEntities, DateTime.UtcNow);


            //db.Labels.Add(entityDTO);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = label.ID }, label));
        }
Exemplo n.º 28
0
 public GetLabel(LabelDTO label, LabellingServer controller) : base(label, controller)
 {
 }
Exemplo n.º 29
0
 /// <summary>
 /// Adds the label.
 /// </summary>
 /// <param name="label">The label.</param>
 /// <returns></returns>
 public LabelDTO AddLabel(LabelDTO label)
 {
     return(_labelService.AddLabel(label));
 }
Exemplo n.º 30
0
 public BaseStep(LabelDTO label, LabellingServer server)
 {
     Label  = label;
     Server = server;
 }