public static Userstories SearchUserById(Userstories p, EmpDBContext db) { Userstories z = (db.userstories.Where(e => e.userstoryid == p.userstoryid)).First(); return(z); }
public static void CreateNewUserstories(Userstories userstory) { EmpDBContext db = new EmpDBContext(); db.userstories.Add(userstory); db.SaveChanges(); }
// GET: api/UserStory/5 public Userstories Get(int id) { Userstories story = new Userstories(); story.userstoryid = id; return(UserStoriesRepository.SearchStory(story)); }
// DELETE: api/UserStory/5 public void Delete(int id) { Userstories user = new Userstories(); user.userstoryid = id; UserStoriesRepository.DeleteStory(user); }
public static void CreateStory(Userstories story) { ProjectEntiryDbcontext db = new ProjectEntiryDbcontext(); db.Userstories.Add(story); db.SaveChanges(); }
public static void DeleteStory(Userstories story) { ProjectEntiryDbcontext db = new ProjectEntiryDbcontext(); Userstories u = UserStoriesRepository.SearchStory(story, db); db.Userstories.Remove(u); db.SaveChanges(); }
// GET: api/Userstories/5 public Userstories Get(int id) { EmpDBContext db = new EmpDBContext(); Userstories pr = new Userstories(); pr.userstoryid = id; return(UserstoryRepo.SearchUserById(pr, db)); }
public static void Edit(Userstories user) { ProjectEntiryDbcontext db = new ProjectEntiryDbcontext(); Userstories u = SearchStory(user, db); u.projectid = user.projectid; u.story = user.story; db.SaveChanges(); }
public static void EditUserstories(Userstories e) { EmpDBContext db = new EmpDBContext(); Userstories usr = SearchUserById(e, db); usr.story = e.story; usr.proid = e.proid; db.SaveChanges(); }
static async Task Main(string[] args) { //Creates a UdpClient for reading incoming data. UdpClient udpServer = new UdpClient(7065); //Creates an IPEndPoint to record the IP Address and port number of the sender. //IPAddress ip = IPAddress.Parse("192.168.103.148"); IPEndPoint RemoteIpEndPoint = new IPEndPoint(IPAddress.Any, 7065); //IPEndPoint object will allow us to read datagrams sent from another source. try { // Blocks until a message is received on this socket from a remote host (a client). Console.WriteLine("Server is listening"); Byte[] receiveBytes = udpServer.Receive(ref RemoteIpEndPoint); //Server is now activated"); string receivedData = Encoding.ASCII.GetString(receiveBytes); string[] data = receivedData.Split(' '); //string text = data[1] + data[2]; Console.WriteLine(receivedData); //Console.WriteLine("Received from: " + clientName.ToString() + " " + text.ToString()); Userstories recData = JsonConvert.DeserializeObject <Userstories>(receivedData); Console.WriteLine($"{recData.Id} {recData.Title} temp is {recData.Description}"); Console.WriteLine("This message was sent from " + RemoteIpEndPoint.Address.ToString() + " on their port number " + RemoteIpEndPoint.Port.ToString()); await Post <Userstories, Userstories>("https://proeverest.azurewebsites.net/api/UserStories", recData); } catch (Exception e) { Console.WriteLine(e.ToString()); } }
// PUT: api/UserStory/5 public void Put(int id, Userstories story) { story.userstoryid = id; UserStoriesRepository.Edit(story); }
// POST: api/UserStory public void Post(Userstories story) { UserStoriesRepository.CreateStory(story); }
public static void Main(string[] args) { // Userstories userstories = new Userstories(); // AcceptanceCriterias criteria = new AcceptanceCriterias(); //create clone var co = new CloneOptions(); co.CredentialsProvider = (_url, _user, _cred) => new UsernamePasswordCredentials { Username = USERNAME, Password = PASSWORD }; Repository.Clone("https://github.com/Yashashree-Salunke/UserStoriesFeature.git", "C:/Users/admin/Documents/GitHub/UserStoriesFeature"); using (var repo = new Repository(@"C:/Users/admin/Documents/GitHub/UserStoriesFeature")) { var db = new ReqSpecContextContext(); DirectoryInfo ParentDirectory = new DirectoryInfo(repo.Info.WorkingDirectory); foreach (var u in db.Userstories) { if (u.RootId == null && u.ParentId == null) { if (u.HasChildren == true) { var FolderName = u.Title.Replace(" ", "_"); var Folder = Directory.CreateDirectory( Path.Combine(ParentDirectory.FullName, FolderName)); string title = u.Title.Replace(" ", ""); string fullpath = Path.Combine(repo.Info.WorkingDirectory, title + ".Feature"); var tag = (from t in db.Tags join us in db.UserstoryTags on t.Id equals us.TagId where us.UserstoryId == u.Id select t.Title).SingleOrDefault(); var scenario = (from ac in db.AcceptanceCriterias join us in db.Userstories on ac.UserstoryId equals us.Id where ac.UserstoryId == u.Id select ac.Title).SingleOrDefault(); var GWT = (from ac in db.AcceptanceCriterias join us in db.Userstories on ac.UserstoryId equals us.Id where ac.UserstoryId == u.Id select ac.Gwt).SingleOrDefault(); var contents = "Feature:" + u.Title + "\n" + u.Description + "\n" + "@" + tag + "\n" + "Scenario:" + scenario + "\n" + "\t" + GWT; File.WriteAllText(fullpath, contents); repo.Index.Add(title + ".Feature"); Commands.Stage(repo, fullpath); } else { string title = u.Title.Replace(" ", ""); string fullpath = Path.Combine(ParentDirectory.FullName, title + ".Feature"); var tag = (from t in db.Tags join us in db.UserstoryTags on t.Id equals us.TagId where us.UserstoryId == u.Id select t.Title).SingleOrDefault(); var scenario = (from ac in db.AcceptanceCriterias join us in db.Userstories on ac.UserstoryId equals us.Id where ac.UserstoryId == u.Id select ac.Title).SingleOrDefault(); var GWT = (from ac in db.AcceptanceCriterias join us in db.Userstories on ac.UserstoryId equals us.Id where ac.UserstoryId == u.Id select ac.Gwt).SingleOrDefault(); var content = "Feature:" + u.Title + "\n" + u.Description + "\n" + "@" + tag + "\n" + "Scenario:" + scenario + "\n" + "\t" + GWT; File.WriteAllText(fullpath, content); repo.Index.Add(title + ".Feature"); Commands.Stage(repo, fullpath); } } if (u.ParentId != null) { if (u.HasChildren == true) { CreateFolder(); } else { string Filename = u.Title.Replace(" ", ""); var title = (from s in db.Userstories where s.Id == u.ParentId select s.Title).Single(); List <string> folders = ParentDirectory.GetDirectories(title.Replace(" ", "_"), SearchOption.AllDirectories).Select(p => p.FullName).ToList(); string Fullpath = folders.Single(); string newpath = Path.Combine(Fullpath, Filename + ".Feature"); int fileIndex = repo.Info.WorkingDirectory.Count(); string file = newpath.Remove(0, fileIndex); var tag = (from t in db.Tags join us in db.UserstoryTags on t.Id equals us.TagId where us.UserstoryId == u.Id select t.Title).SingleOrDefault(); var scenario = (from ac in db.AcceptanceCriterias join us in db.Userstories on ac.UserstoryId equals us.Id where ac.UserstoryId == u.Id select ac.Title).SingleOrDefault(); var GWT = (from ac in db.AcceptanceCriterias join us in db.Userstories on ac.UserstoryId equals us.Id where ac.UserstoryId == u.Id select ac.Gwt).SingleOrDefault(); var content = "Feature:" + u.Title + "\n" + u.Description + "\n" + "@" + tag + "\n" + "Scenario:" + scenario + "\n" + "\t" + GWT; File.WriteAllText(newpath, content); repo.Index.Add(file); Commands.Stage(repo, newpath); } } void CreateFolder() { List <Userstories> list = new List <Userstories>(); string connectionString = "Server=(localdb)\\mssqllocaldb;Database=ReqSpecContext;Trusted_Connection=True;MultipleActiveResultSets=true"; SqlConnection con = new SqlConnection(connectionString); SqlCommand command = new SqlCommand("SELECT Id,HasChildren,ParentId,Title FROM UserStories"); command.Connection = con; command.Connection.Open(); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { Userstories us = new Userstories(); us.Id = (int)reader["Id"]; us.HasChildren = (bool)reader["HasChildren"]; if (reader["ParentId"] == DBNull.Value) { us.ParentId = 0; } else { us.ParentId = (int)reader["ParentId"]; } us.Title = (string)reader["Title"]; list.Add(us); } foreach (var item in list) { if (item.ParentId == u.ParentId) { var FolderName = item.Title.Replace(" ", "_"); var title = list.Where(x => x.Id == item.ParentId).Select(p => p.Title).Single(); List <string> folders = ParentDirectory.GetDirectories(title.Replace(" ", "_"), SearchOption.AllDirectories).Select(p => p.FullName).ToList(); string Fullpath = folders.Single(); var folder = Directory.CreateDirectory(Path.Combine(Fullpath, FolderName)); string file = u.Title.Replace(" ", ""); string filepath = Path.Combine(Fullpath, title + ".Feature"); var tag = (from t in db.Tags join us in db.UserstoryTags on t.Id equals us.TagId where us.UserstoryId == u.Id select t.Title).Single(); var scenario = (from ac in db.AcceptanceCriterias join us in db.Userstories on ac.UserstoryId equals us.Id where ac.UserstoryId == u.Id select ac.Title).Single(); var GWT = (from ac in db.AcceptanceCriterias join us in db.Userstories on ac.UserstoryId equals us.Id where ac.UserstoryId == u.Id select ac.Gwt).Single(); var content = "Feature:" + u.Title + "\n" + u.Description + "\n" + "@" + tag + "\n" + "Scenario:" + scenario + "\n" + "\t" + GWT; File.WriteAllText(filepath, content); repo.Index.Add(title + ".Feature"); Commands.Stage(repo, filepath); } } } } PushAndCommit(); void PushAndCommit() { Signature author = new Signature("Yashashree-Salunke", USERNAME, DateTime.Now); Signature committer = author; Commit commit = repo.Commit("Feature is added", author, committer); // Commit to the repository PushOptions options = new PushOptions(); options.CredentialsProvider = new CredentialsHandler( (url, usernameFromUrl, types) => new UsernamePasswordCredentials() { Username = USERNAME, Password = PASSWORD }); repo.Network.Push(repo.Branches["master"], options); } } }
public static Userstories SearchStory(Userstories story) { ProjectEntiryDbcontext db = new ProjectEntiryDbcontext(); return((db.Userstories.Select(s => s).Where(s => s.userstoryid == story.userstoryid)).First()); }
// PUT: api/Userstories/5 public void Put(int id, Userstories value) { value.userstoryid = id; UserstoryRepo.EditUserstories(value); }
// POST: api/Userstories public void Post(Userstories usr) { UserstoryRepo.CreateNewUserstories(usr); }