public async Task <ActionResult <List> > Create([FromBody] List newList)
        {
            try
            {
                Profile userInfo = await HttpContext.GetUserInfoAsync <Profile>();

                newList.CreatorId = userInfo.Id;
                List createdNew = _bs.Create(newList);
                return(Ok(createdNew));
            }
            catch (System.Exception err)
            {
                return(BadRequest(err.Message));
            }
        }
Esempio n. 2
0
        public ActionResult PartnerCreate(ListItemLocal model)
        {
            model.Id = ListService.Create(model);
            var relativePath = ConfigurationManager.AppSettings["saveImagesIn"];

            if (model.Logo != null)
            {
                Functions.SaveFile(model.Logo, relativePath, Server.MapPath(relativePath), model.Id + "_Logo");
            }
            if (model.Background != null)
            {
                Functions.SaveFile(model.Background, relativePath, Server.MapPath(relativePath), model.Id + "_Background");
            }
            ListService.UpdateImages(model);
            return(RedirectToAction("View"));
        }
Esempio n. 3
0
        public void Create_saves_a_list_via_context()
        {
            var mockSet = new Mock <DbSet <List> >();

            var mockContext = new Mock <TrelloDbContext>();

            mockContext.Setup(m => m.tblList).Returns(mockSet.Object);

            var service = new ListService(mockContext.Object);

            service.Create(new List()
            {
                Title = "List A"
            });

            mockSet.Verify(m => m.Add(It.IsAny <List>()), Times.Once());
            mockContext.Verify(m => m.SaveChanges(), Times.Once());
        }
        public void Run()
        {
            var now         = DateTime.UtcNow;
            var nowString   = now.ToString("yyyyMMddHHmmss");
            var initialName = "b-" + nowString;
            var updateName  = "a-" + nowString;

            using (var service = new ListService())
            {
                // Create a list
                var afterCreate = service.Create(new CreateListParameters(initialName, initialName, 1));

                // Update the list
                var afterUpdate = service.Update(afterCreate.Id, new UpdateListParameters(updateName, updateName, 1));

                // Get 8 lists, with page size of 3
                var lists = service.GetIndex(3).SetLimit(8).ToList();

                // Get 1 page of lists, size 3
                var listPages = service.GetIndexAsPages(3).SetLimit(1).ToList();

                // Add people to the list
                service.AddPeople(afterCreate.Id, Enumerable.Range(1, 100).ToList());

                // Get the people in the list
                var people = service.GetPeople(afterCreate.Id).ToList();

                // Remove some of the people from the list
                service.RemovePeople(afterCreate.Id, Enumerable.Range(50, 80).ToList());

                // Add a tag to the people in the list
                service.AddTag(afterCreate.Id, "nbc_testtag1");

                // Remove the tag from the people in the list
                service.RemoveTag(afterCreate.Id, "nbc_testtag1");

                // Delete the list
                service.Delete(afterCreate.Id);
            }
        }
Esempio n. 5
0
        public IActionResult Create([FromBody] List list)
        {
            ValidationResult valresult = listvalidator.Validate(list);
            List             result;

            list.Id = ObjectId.GenerateNewId().ToString();
            if (!valresult.IsValid)
            {
                return(BadRequest("Make sure title and description are filled in"));
            }

            try
            {
                result = _listService.Create(list);
            }
            catch (Exception e)
            {
                return(CreatedAtRoute("returnError", e.ToString()));
            }

            return(CreatedAtRoute("getList", new { id = list.Id.ToString() }));
        }
Esempio n. 6
0
        public IActionResult Create(List list)
        {
            var findallproject = _listService.GetProjectById(list.projectId);

            if (findallproject == null)
            {
                list.index = 0;
            }
            else
            {
                int highestindex = 0;
                foreach (var i in findallproject)
                {
                    if (i.index >= highestindex)
                    {
                        highestindex = i.index;
                    }
                }
                list.index = highestindex + 1;
            }
            _listService.Create(list);
            var findallreport = _reportService.GetByProjectId(list.projectId);

            Console.WriteLine("projects{0}", JsonConvert.SerializeObject(findallreport));
            if (findallreport == null)
            {
                Console.WriteLine("list");
                Report report = new Report();
                report.project_id = list.projectId;
                UserStories        us    = new UserStories();
                List <UserStories> _list = new List <UserStories>();
                var listData             = _listService.GetProjectById(list.projectId);
                foreach (var x in listData)
                {
                    if (x.name == list.name)
                    {
                        us.id    = x.Id;
                        us.label = x.name;
                        us.date  = DateTime.Today;
                        TimeSpan timeSpan = new TimeSpan(00, 00, 00, 00);
                        us.date = us.date.Date + timeSpan;
                        List <string> userIDs = new List <string>();
                        us.userstoryid = userIDs;
                        _list.Add(us);
                        report.list = _list;
                        Console.WriteLine("Repport:{0}", JsonConvert.SerializeObject(report));
                        _reportService.Create(report);
                        break;
                    }
                }
            }
            else
            {
                UserStories us       = new UserStories();
                var         listData = _listService.GetProjectById(list.projectId);
                foreach (var x in listData)
                {
                    if (x.name == list.name)
                    {
                        us.id    = list.Id;
                        us.label = list.name;
                        us.date  = DateTime.Today;
                        TimeSpan timeSpan = new TimeSpan(12, 00, 00);
                        us.date = us.date.Date + timeSpan;
                        List <string> userIDs = new List <string>();
                        us.userstoryid = userIDs;
                        Console.WriteLine("Got Reports:{0}", JsonConvert.SerializeObject(findallreport));
                        findallreport.list.Add(us);
                        Console.WriteLine("Reports:{0}", JsonConvert.SerializeObject(findallreport));
                        _reportService.UpdateAll(findallreport.project_id, findallreport);
                        Console.WriteLine("Fetched Report:{0}", JsonConvert.SerializeObject(_reportService.GetByProjectId(list.projectId)));
                    }
                }
            }



            Logger actlog = new Logger()
            {
                type        = "Activity@CreateList",
                id          = HttpContext.User.Claims.Where(c => c.Type == "id").FirstOrDefault().Value,
                description = _userService.Get(HttpContext.User.Claims.Where(c => c.Type == "id").FirstOrDefault().Value).username + " created a list named "
                              + list.name,
                published = DateTime.Now,
                data      = new Data()
                {
                    id   = list.Id,
                    name = list.name
                }
            };
            RabbitMQProducer actProducer = new RabbitMQProducer();

            actProducer.SendMessageToActivityLogger(actlog);

            Logger log = new Logger()
            {
                type        = "KanBan@CreateList",
                id          = HttpContext.User.Claims.Where(c => c.Type == "id").FirstOrDefault().Value,
                description = "List created",
                published   = DateTime.Now,
                data        = new Data()
                {
                    id   = list.Id,
                    name = list.name
                }
            };
            RabbitMQProducer producer = new RabbitMQProducer();

            producer.SendMessageToLogger(log);
            Console.WriteLine(log);


            return(CreatedAtRoute("GetList", new { id = list.Id.ToString() }, list));
        }
Esempio n. 7
0
        public static void ReceivefromIdeaZone()
        {
            _channel = _connection.CreateModel();
            {
                var queueName = _channel.QueueDeclare(
                    queue: IdeaZoneQueueName,
                    durable: true,
                    exclusive: false,
                    autoDelete: false,
                    arguments: null);


                // _channel.ExchangeDeclare(exchange: "logs", type: ExchangeType.Fanout);


                Console.WriteLine(" [*] Waiting for Ideas.");

                var consumer = new EventingBasicConsumer(_channel);
                consumer.Received += (model, ea) =>
                {
                    //Console.WriteLine("coming here");
                    var    body    = ea.Body;
                    string message = Encoding.Default.GetString(body);
                    Console.WriteLine(" [x] ----> {0}", message);
                    var userstoryfromidea = JsonConvert.DeserializeObject <UserStoryIdeas>(message);



                    Console.WriteLine("Object:{0}", userstoryfromidea.linkedtoId);
                    //KanbanUserStory sendData = new KanbanUserStory();
                    //  sendData = GetUserStoryfromGantt(sendData,userstory);
                    //  userService.Create(sendData);
                    //  Console.WriteLine("text:{0}",sendData);

                    //b.SendUserStoryToAddOnList(userstoryfromidea.projectId,"success");
                    //Clients.Group(userstoryfromidea.projectId).SendAsync("RabbitListUpdate","success");

                    if (userstoryfromidea.action == "post")
                    {
                        KanbanUserStory sendData = new KanbanUserStory();
                        sendData.uniqueId  = userstoryfromidea.linkedtoId;
                        sendData.shortName = userstoryfromidea.description;
                        //sendData.acceptanceCriteria = userstoryfromidea.acceptanceCriteria;

                        if (userstoryfromidea.acceptanceCriteria == null)
                        {
                            sendData.acceptanceCriteria = new string[0] {
                            };
                        }
                        else
                        {
                            sendData.acceptanceCriteria = userstoryfromidea.acceptanceCriteria;
                        }
                        sendData.linkedToId = userstoryfromidea.linkedtoId;
                        sendData.startTime  = DateTime.Now;
                        sendData.endTime    = DateTime.Now;
                        sendData.status     = "Product Backlog";
                        //sendData.linkedToId = userstoryfromidea.linkedtoId;
                        sendData.projectId  = userstoryfromidea.projectId;
                        sendData.tasks      = new USTask[0] {
                        };
                        sendData.assignedTo = new AssignedTo[0] {
                        };
                        sendData.startTime  = DateTime.Now;
                        sendData.endTime    = DateTime.Now;

                        //sendData.progress = userstoryfromidea.progress;
                        var userstoryCreated = userService.Create(sendData);

                        //var kanbanUS = userService.GetByProjectId(userstoryfromidea.projectId);
                        var listobj = listService.GetByProjectIdAndPB(sendData.projectId);

                        if (listobj == null)
                        {
                            Console.WriteLine("Inside list obj == null");
                            List objr = new List()
                            {
                                name      = "Product Backlog",
                                projectId = sendData.projectId,
                                index     = 0,
                                UserStory = new UserStory[1] {
                                    new UserStory()
                                    {
                                        UserStoryId   = userstoryCreated.Id,
                                        UserStoryName = sendData.shortName
                                    }
                                }
                            };
                            listService.Create(objr);
                        }
                        else
                        {
                            Console.WriteLine("obj not null so updating list");
                            //List<UserStory> obj=listobj.UserStory.ToList();
                            UserStory abc = new UserStory()
                            {
                                UserStoryId   = userstoryCreated.Id,
                                UserStoryName = sendData.shortName
                            };


                            //listobj.UserStory=listobj.UserStory.Concat(abc).ToArray();

                            // Array.Resize(ref listobj.UserStory, listobj.UserStory.Length + 1);
                            // listobj.UserStory[listobj.UserStory.Length - 1] = abc;
                            List <UserStory> uslist = new List <UserStory>();
                            for (int i = 0; i < listobj.UserStory.Length; i++)
                            {
                                uslist.Add(listobj.UserStory[i]);
                            }
                            uslist.Add(abc);
                            listobj.UserStory = uslist.ToArray();

                            // listobj.UserStory=listobj.UserStory.ToList().Add(new UserStory(){UserStoryId=userstoryCreated.Id,
                            // UserStoryName=sendData.shortName}).ToArray();///
                            listService.Update(listobj.Id, listobj);
                        }
                        //userService.SendRabbit(userstoryfromidea.projectId);
                        //var kmm=RabbitMQReceiver.b.SendUserStoryToAddOnList(userstoryfromidea.projectId,"aadasdasd");
                    }
                    else if (userstoryfromidea.action == "delete")
                    {
                        Console.WriteLine("inside delete now");
                        var getuserstory = userService.GetByUniqueId(userstoryfromidea.linkedtoId);
                        userService.RemoveByUniqueId(userstoryfromidea.linkedtoId);
                        var allLists      = listService.GetProjectById(userstoryfromidea.projectId);
                        var linkedToCards = userService.GetByLinkedId(userstoryfromidea.linkedtoId);
                        // Console.WriteLine(linkedToCards+"linked");
                        foreach (var i in linkedToCards)
                        {
                            userService.Remove(i.Id);
                            Console.WriteLine(i.shortName);
                            foreach (var j in allLists)
                            {
                                List <UserStory> linklist = new List <UserStory>();
                                foreach (var k in j.UserStory)
                                {
                                    if (k.UserStoryId != i.Id)
                                    {
                                        linklist.Add(k);
                                    }
                                }
                                j.UserStory = linklist.ToArray();
                                listService.Update(j.Id, j);
                            }
                        }
                        string listidwherefound = allLists[0].Id;
                        foreach (var i in allLists)
                        {
                            foreach (var j in i.UserStory)
                            {
                                if (j.UserStoryId == getuserstory.Id)
                                {
                                    listidwherefound = i.Id;
                                    Console.WriteLine("list id {0}", listidwherefound);
                                }
                            }
                        }

                        var listobj = listService.Get(listidwherefound);
                        //var listobj=listwhereidfound.UserStory;
                        List <UserStory> uslist = new List <UserStory>();
                        for (int i = 0; i < listobj.UserStory.Length; i++)
                        {
                            if (listobj.UserStory[i].UserStoryId == getuserstory.Id)
                            {
                            }
                            else
                            {
                                uslist.Add(listobj.UserStory[i]);
                            }
                        }
                        //uslist.Add(abc);
                        listobj.UserStory = uslist.ToArray();
                        listService.Update(listobj.Id, listobj);
                    }


                    //else if (taskfromgantt.action == "delete")
                    //{
                    //    var kanbanUS = userService.GetByUniqueId(taskfromgantt.unique_id);
                    //    if (kanbanUS == null)
                    //    {

                    //    }
                    //    else
                    //    {
                    //        userService.Remove(kanbanUS.Id);
                    //    }

                    //}
                };
                _channel.BasicConsume(queue: IdeaZoneQueueName,
                                      autoAck: true,
                                      consumer: consumer
                                      );


                Console.WriteLine(" Press [enter] to exit.");
                // Console.ReadLine();
            }
        }