Esempio n. 1
0
        public async Task <IActionResult> PostRecepient([FromBody] Clean clean)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            User user = new User();

            user.email    = clean.username;
            user.password = clean.password;
            user.role     = "Recepient";
            _context.users.Add(user);
            await _context.SaveChangesAsync();

            Recepient recepient = new Recepient();

            recepient.name        = clean.name;
            recepient.location    = clean.location;
            recepient.phoneNumber = clean.phone;
            recepient.userId      = _context.users.FirstOrDefault(x => x.email == clean.username).userId;
            recepient.user        = user;
            _context.recepients.Add(recepient);
            await _context.SaveChangesAsync();

            recepient = _context.recepients.Include(e => e.user).FirstOrDefault(e => e.recepientId == recepient.recepientId);

            return(CreatedAtAction("GetRecepient", new { recepientId = recepient.recepientId }, recepient));
        }
Esempio n. 2
0
        public async Task <IActionResult> PutRecepient([FromRoute] int recepientId, [FromBody] Recepient recepient)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (recepientId != recepient.recepientId)
            {
                return(BadRequest());
            }

            _context.Entry(recepient).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RecepientExists(recepientId))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            recepient = _context.recepients.Include(e => e.user).FirstOrDefault(e => e.recepientId == recepient.recepientId);
            return(Ok(recepient));
        }
        public Campaign[] GetCampaignsOf(Recepient recepient)
        {
            ParallelFetch("Receives_From", "Campaign");
            var res = from entry in dataSet.Tables["Receives_From"].AsEnumerable()
                      join entry2 in dataSet.Tables["Campaign"].AsEnumerable()
                      on entry.Field <int>("Campaign_ID") equals entry2.Field <int>("ID_")
                          where entry.Field <int>("Recepient_SSN") == recepient.SSN
                      select QuerySelect <Campaign>(entry2);

            return(res.ToArray());
        }
Esempio n. 4
0
 /// <summary>
 /// Method write and send letter to other account.
 /// </summary>
 /// <param name="recepient"></param>
 /// <param name="content">Content of message</param>
 public void SendLetter(string recepient, string content)
 {
     Wait.Until(t => Driver.FindElements(By.XPath(Locator.RecepientLocator)).Any());
     Recepient = Driver.FindElement(By.XPath(Locator.RecepientLocator));
     Recepient.SendKeys(recepient);
     Wait.Until(t => Driver.FindElements(By.XPath(Locator.SwitcherToFrameLocator)).Any());
     Driver.SwitchTo().Frame(Driver.FindElement(By.XPath(Locator.SwitcherToFrameLocator)));
     Wait.Until(t => Driver.FindElements(By.XPath(Locator.TextLocator)).Any());
     Text = Driver.FindElement(By.XPath(Locator.TextLocator));
     Text.Clear();
     Text.SendKeys(content);
     Driver.SwitchTo().ParentFrame();
     Wait.Until(t => Driver.FindElements(By.XPath(Locator.SendButtonLocator)).Any());
     SentButton = Driver.FindElement(By.XPath(Locator.SendButtonLocator));
     SentButton.Click();
     Wait.Until(t => Driver.FindElements(By.XPath(Locator.LetterSentLocator)).Any());
 }
        public Item[] GetItemsReceivedBy(Recepient recepient)
        {
            ParallelFetch("Receives_From", "Item");
            var res = from entry in dataSet.Tables["Receives_From"].AsEnumerable()
                      join entry2 in dataSet.Tables["Item"].AsEnumerable()
                      on new
            {
                Name     = entry.Field <string>("ItemName"),
                MainName = entry.Field <string>("ItemMainName"),
                SubName  = entry.Field <string>("ItemSubName")
            }
            equals new
            {
                Name     = entry2.Field <string>("Name_"),
                MainName = entry2.Field <string>("MainName"),
                SubName  = entry2.Field <string>("SubName")
            }
            select QuerySelect <Item>(entry2);

            return(res.ToArray());
        }
Esempio n. 6
0
 public Campaign[] GetCampaignsOf(Recepient recepient)
 {
     throw new NotImplementedException();
 }
Esempio n. 7
0
 public Item[] GetItemsReceivedBy(Recepient recepient)
 {
     throw new NotImplementedException();
 }
 public Campaign[] GetCampaignsOf(Recepient recepient)
 {
     return FillList<Campaign>(@"select * from campaign c , Receives_From rf where c.id_=rf.Campaign_ID 
                               and rf.Recipient_SSN=:recipientSSN ",
                               new KeyValuePair<string, object>("recipientSSN", recepient.SSN));
 }
Esempio n. 9
0
 public Item[] GetItemsReceivedBy(Recepient recepient)
 {
     return(dbLayer.GetItemsReceivedBy(recepient));
 }
Esempio n. 10
0
 public Campaign[] GetCampaignsOf(Recepient recepient)
 {
     return(dbLayer.GetCampaignsOf(recepient));
 }
Esempio n. 11
0
 public Item[] GetItemsReceivedBy(Recepient recepient)
 {
     return(FillList <Item>("select * from Receives_From RF where RF.Recipient_SSN = :RSSN", null,
                            new KeyValuePair <string, object>("RSSN", recepient.SSN)));
 }