Пример #1
0
 public ActionResult RemoveWomanWomanMessage(int messageId, UserMessageModel model)
 {
     var womanWomanClient = new WomanWomanClient();
     womanWomanClient.RemoveWomanWomanMessages(messageId);
     return View("WomanWoman", model);
 }
Пример #2
0
 public ActionResult RemoveManManMessage(int messageId, UserMessageModel model)
 {
     var manManClient = new ManManClient();
     manManClient.RemoveManManMessages(messageId);
     return View("ManManChat", model);
 }
Пример #3
0
 public ActionResult Index()
 {
     var model = new UserMessageModel();
     return View(model);
 }
Пример #4
0
        public ActionResult AddUser(UserMessageModel model)
        {
            var manManClient = new ManManClient();
            var womanWomanClient = new WomanWomanClient();
            var manWomanclient = new ManWomanClient();

            if (!ModelState.IsValid) return View("Index");
            if (model.Gender == "Male")
            {
                var addUser = new User
                {
                    Gender = model.Gender,
                    Username = model.Username,
                };
                manManClient.AddManUser(addUser);
            }

            if (model.Gender == "Female")
            {
                var addUser = new User
                {
                    Gender = model.Gender,
                    Username = model.Username,
                };
                womanWomanClient.AddWomanUser(addUser);
            }

            if (model.ChatRoom == "Male-Male" && model.Gender == "Male")
            {
                var manUser = new User
                {
                    Username = model.Username,
                    Gender = model.Gender
                };
                manManClient.AddManUser(manUser);
                var users = manManClient.GetManUsers();
                foreach (var user in users  )
                {
                    model.UserList.Add(user);
                    model.UserJoin= $"{user.Username} loggade in {DateTime.Now.ToShortTimeString()}";
                }

                return View("ManManChat", model);
            }
            if (model.ChatRoom == "Male-Male" && model.Gender == "Female")
            {
                ViewBag.Error = "Endast män i denna chatten!";
            }

            if ((model.ChatRoom == "Male-Woman"))
            {
                {
                    var manWomanUser = new User
                    {
                        Username = model.Username,
                        Gender = "Unisex"
                    };
                    model.Gender = "Unisex";
                    manWomanclient.AddManWomanUser(manWomanUser);
                    var users = manWomanclient.GetManWomanUser();
                    foreach (var user in users)
                    {
                        model.UserList.Add(user);
                        model.UserJoin = $"{user.Username} loggade in {DateTime.Now.ToShortTimeString()}";
                    }
                    return View("MaleWoman", model);
                }
            }

            if (model.ChatRoom == "Woman-Woman" && model.Gender == "Female")
            {
                var womanWomanUser = new User
                {
                    Username = model.Username,
                    Gender = model.Gender
                };
                womanWomanClient.AddWomanUser(womanWomanUser);
                var users = womanWomanClient.GetWomanUser();
                foreach (var user in users)
                {
                    model.UserList.Add(user);
                    model.UserJoin = $"{user.Username} loggade in {DateTime.Now.ToShortTimeString()}";
                }
                return View("WomanWoman", model);
            }
            if (model.ChatRoom == "Woman-Woman" && model.Gender == "Male")
            {
                ViewBag.Error = "Endast kvinnor i denna chatten!";
            }
            return View("Index");
        }
Пример #5
0
        public ActionResult AddNewMessage(UserMessageModel model)
        {
            if (!ModelState.IsValid) return View("Index");
            switch (model.ChatRoom)
            {
                case "Male-Male":
                    try
                    {
                        var manClient = new ManManClient();
                        var manMessage = model.Message;
                        manMessage.Username = model.Username;
                        manMessage.TimeSubmitted = DateTime.Now;
                        manClient.SubmitManManMessages(manMessage);
                        var users = manClient.GetManUsers();
                        foreach (var user in users)
                        {
                            model.UserList.Add(user);
                        }
                        ModelState.Clear();
                        model.Message.Message = "";
                        return View("ManManChat", model);
                    }
                    catch (FaultException e)
                    {
                        ViewBag.Error = $"An error has occured, see details: {e.Message}";
                    }
                    catch (Exception ex)
                    {
                        ViewBag.Error = $"An error has occured, see details: {ex.Message}";
                    }
                    break;
                case "Woman-Woman":
                    try
                    {
                        var womanClient = new WomanWomanClient();
                        var womanMessage = model.Message;
                        womanMessage.Username = model.Username;
                        womanMessage.TimeSubmitted = DateTime.Now;
                        womanClient.SubmitWomanWomanMessages(womanMessage);
                        var users = womanClient.GetWomanUser();
                        foreach (var user in users)
                        {
                            model.UserList.Add(user);
                        }
                        ModelState.Clear();
                        model.Message.Message = "";
                        return View("WomanWoman", model);
                    }
                    catch (FaultException e)
                    {
                        ViewBag.Error = $"An error has occured, see details: {e.Message}";
                    }
                    catch (Exception ex)
                    {
                        ViewBag.Error = $"An error has occured, see details: {ex.Message}";
                    }
                    break;
                case "Male-Woman":
                    try
                    {
                        var maleWomanClient = new ManWomanClient();
                        var maleWomanMessage = model.Message;
                        maleWomanMessage.Username = model.Username;
                        maleWomanMessage.TimeSubmitted = DateTime.Now;
                        maleWomanClient.SubmitManWomanMessages(maleWomanMessage);
                        var users = maleWomanClient.GetManWomanUser();
                        foreach (var user in users)
                        {
                            model.UserList.Add(user);
                        }
                        ModelState.Clear();
                        model.Message.Message = "";
                        return View("MaleWoman", model);
                    }
                    catch (FaultException e)
                    {
                        ViewBag.Error = $"An error has occured, see details: {e.Message}";

                    }
                    catch (Exception ex)
                    {
                        ViewBag.Error = $"An error has occured, see details: {ex.Message}";
                    }
                    break;
            }
            return View("Index");
        }