0

So I have this Feedback MVC app I'm working on and one of the final parts I need to do is basically what I mentioned above. I'll give you the quick run down. Main screen, somebody searches a whom they are after and it brings back the result. Upon clicking the desired name it will bringup a form, already auto-completed with the user who searched in the Sender field, and the person who they searched for in the recipient. Brilliant, the form gets sent. Feedback saved to database. Quite basic, but I'm in learning so pretty proud of that.

Now, once the form has been sent I would in turn like an email to get sent to the colleagues manager/supervisor, which I have information on, stored on the database. Now this is no where near finished code and I realise I have a bit of tidying up to do and stuff, but is there a specific place to start looking? Is PHP one of them? Apologies if you don't understand some parts of code obviously with db names etc.

Hope I gave enough info here. There's not much more to overly show in regards to the feedback form.

Feedback form HTML

    <h2>Employee Feedback Form</h2>


    <div class="container">
@using (Html.BeginForm("Create", "Home", FormMethod.Post, new { @class = "form" }))
{
    @Html.AntiForgeryToken()
            <div class="row">
                <div class="col-25">
                    <label for="sender">Sender</label>
                </div>
                <div class="col-75">
                    @*<input type="text" id="sender" name="sender" readonly="readonly" placeholder="@Html.DisplayFor(model => model.Sender)">*@
                    @Html.TextBoxFor(model => model.Sender, new { @readonly = "readonly" })

                </div>
            </div>
            <div class="row">
                <div class="col-25">
                    <label for="recep">Recipient</label>
                </div>
                <div class="col-75">
                    @Html.TextBoxFor(model => model.Recipient, new { @readonly = "readonly" })
                </div>
            </div>
            <div class="row">
                <div class="col-25">
                    <label for="feedback">Feedback</label>
                </div>
                <div class="col-75">
                    @*<textarea id="feedback" name="feedback" placeholder="Write something.." style="height:200px"></textarea>*@
                    @Html.TextAreaFor(model => model.Comment)
                </div>

            </div>
            <div class="row">
                <input type="submit" value="Submit" onclick="return confirm('Are you sure you want to submit feedback?')"/>
            </div>
}
    </div>

</body>

Feedback Form View Model

    public class FeedbackFormViewModel
    {

        public string Recipient { get; set; }

        public string Sender { get; set; }

        public string FullName { get; set; }

        public string Comment { get; set; }

    }
}

Feedback Form Action on Controller

 public ActionResult FeedbackForm(string recep, string send)


  {
        var viewModel = new FeedbackFormViewModel();
        viewModel.Recipient = recep;
        viewModel.Sender = GetUserFullName();
        return View(viewModel);
    }

ActionResult to save to database

public ActionResult Create(FeedbackFormViewModel viewModel)
        {
            if (ModelState.IsValid)
            {

                var feedback = new THANKYOU
                {
                    SENDER = viewModel.Sender,
                    RECEIPIENT = viewModel.Recipient,
                    COMMENT = viewModel.Comment
                };

                db.THANKYOUs.Add(feedback);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View();
        }

Really appreciate any help or documentation I could read up on that might help me.

Thanks

Twiggy
  • 3
  • 3
  • 1
    " Is PHP one of them?"...er, no, PHP is another server-side language, competing with ASP.NET. If you're using ASP.NET you don't need PHP as well. – ADyson Jul 25 '18 at 15:25
  • If you google "C# send email" you should find plenty of info to get you going. Obviously you'll need to piece together the _contents_ of your email from the info coming from your form and your database, but the _process_ of sending an email is more or less the same every time. I am assuming you have an email server available which you are allowed to connect to in order to send the mail. – ADyson Jul 25 '18 at 15:25
  • 2
    You need something like this https://stackoverflow.com/questions/9201239/send-e-mail-via-smtp-using-c-sharp – Dan Wilson Jul 25 '18 at 15:26
  • Ok thanks I've not really looked into it yet so i'm not sure what it really is, but I had seen it come up when I done exactly what you've mentioned I did. – Twiggy Jul 25 '18 at 15:27
  • if you googled about C# I'm surprised you got any results back relating to PHP, unless the quality on google has gone down a bit recently. https://www.google.co.uk/search?q=c%23+send+email&oq=C%23+send+email&aqs=chrome.0.0j69i58j69i65j69i60j0l2.294j0j7&sourceid=chrome&ie=UTF-8 certainly there's nothing PHP related on the front page, but there's plenty of other useful stuff. – ADyson Jul 25 '18 at 15:28
  • Thanks @DanWilson I'll look into that. Appreciated. – Twiggy Jul 25 '18 at 15:28
  • 1
    thanks @ADyson I admit I didn't search exactly that as I assumed it would be too bland. I stand corrected, i'll look at a few of them. Cheers. – Twiggy Jul 25 '18 at 15:30
  • .Net Framework has all classes needed for developing a client that sends emails but this also requires an email server. If you don't have one, consider paying a Mandrill subscription for high volume or a free mail server for low volume. You can start trying Gmail for free via C# client. – derloopkat Jul 25 '18 at 15:32

0 Answers0