Ejemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("ID,Question,QuestionID,Authors,QuestionDate,Answer")] QOTDAnswerCreateEditViewModel QOTDAnswerVM, IFormCollection form)
        {
            Debug.Print(QOTDAnswerVM.QuestionID.ToString());

            //not sure I want to allow multiple authors
            // need to swich to creating a different row for each author instead of saving multiple author ids

            string AuthorIds = "";

            foreach (string item in form["Authors"])
            {
                string ite = item;
                AuthorIds += ite + ",,";
            }
            QOTDAnswer qOTDAnswer = new QOTDAnswer();

            qOTDAnswer.Question   = QOTDAnswerVM.Question;
            qOTDAnswer.QuestionID = QOTDAnswerVM.QuestionID;

            qOTDAnswer.Answer       = QOTDAnswerVM.Answer;
            qOTDAnswer.QuestionDate = QOTDAnswerVM.QuestionDate;
            qOTDAnswer.Author       = AuthorIds;
            Debug.Print(qOTDAnswer.Author);

            if (ModelState.IsValid)
            {
                _context.Add(qOTDAnswer);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(qOTDAnswer));
        }
Ejemplo n.º 2
0
        public async Task <int> postjson([FromBody] jsonlistingDTO newListingsPost)
        {//group add for new listings in a JSON format. code duplication with new sales, investingate merging.
            if (newListingsPost is null)
            {
                throw new ArgumentNullException(nameof(newListingsPost));
            }


            foreach (newlistingDTO newthing in newListingsPost.yup)
            {
                USAHomeListing thisListing = new USAHomeListing {
                    Address            = newthing.Address,
                    ZipCode            = newthing.ZipCode,
                    City               = newthing.City,
                    State              = newthing.State,
                    Bedrooms           = newthing.Bedrooms ?? null,
                    Bathrooms          = newthing.Bathrooms ?? null,
                    SquareFootage      = newthing.SquareFootage ?? null,
                    initialPrice       = newthing.initialPrice ?? null,
                    placedOnMarketDate = String.IsNullOrEmpty(newthing.placedOnMarketDate) ?
                                         (DateTimeOffset?)null : DateTimeOffset.Parse(newthing.placedOnMarketDate),
                    insertionDate = DateTimeOffset.Now,
                    Active        = true
                };
                _context.USAHomeListings.Add(thisListing);
            }
            ;

            int result = await _context.SaveChangesAsync();

            Console.WriteLine(result);


            return(result);
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("id,MetroArea,YearBuilt,insertionDate,Creator,RecentEdit")] REProperty rEProperty)
        {
            if (ModelState.IsValid)
            {
                _context.Add(rEProperty);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(rEProperty));
        }
Ejemplo n.º 4
0
        public async Task <bool> AddItemAsync(QOTDAnswer newItem)
        {
            newItem.insertionDate = DateTime.Now;


            _context.QOTDAnswers.Add(newItem);

            var saveResult = await _context.SaveChangesAsync();

            return(saveResult == 1);
        }
      public async Task <IActionResult> Create([Bind("id,Question,QuestionAuthor,QuestionDate,Theme")] ParticipantQOTD Participant)
      {
          if (ModelState.IsValid)
          {
              _context.Add(Participant);
              await _context.SaveChangesAsync();

              return(RedirectToAction(nameof(Index)));
          }
          return(View(Participant));
      }
Ejemplo n.º 6
0
        public async Task <IActionResult> Create([Bind("id,Contractorid,MetroArea,ZipCode,ProjectType,FreeformDescription,insertionDate,Creator")] REProject rEProject)
        {
            if (ModelState.IsValid)
            {
                _context.Add(rEProject);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(rEProject));
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> Create([Bind("id,CreditScore,Lease,Month2Month,FamilyLetter,insertionDate,Creator")] Renter renter)
        {
            if (ModelState.IsValid)
            {
                _context.Add(renter);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(renter));
        }
Ejemplo n.º 8
0
        public async Task <IActionResult> Create([Bind("id,ContractorName,MetroArea,ZipCode,Specialty,insertionDate,Creator")] Contractor contractor)
        {
            if (ModelState.IsValid)
            {
                _context.Add(contractor);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(contractor));
        }
Ejemplo n.º 9
0
        public async Task <bool> AddHouseAsync(USAHomeListing newItem)
        {
            newItem.insertionDate = DateTime.Now;


            _context.USAHomeListings.Add(newItem);

            var saveResult = await _context.SaveChangesAsync();

            return(saveResult == 1);
        }