Exemplo n.º 1
0
        public async Task <ActionResult> SetActive(Guid?userId)
        {
            int      statusCode;
            string   message;
            ExpoUser findedExpoUser = _db.GetCollection <ExpoUser>("ExpoUser").FindById(userId);

            if (findedExpoUser == null)
            {
                return(HttpNotFound());
            }

            if (findedExpoUser.DateOfVisiting != null)
            {
                statusCode = 1;
                message    = "Вы уже прибыли на выставку";
            }
            else
            {
                string subject  = "Спасибо за посещение";
                string msg      = $"Уважаемый(ая){findedExpoUser.UserName}\n Спасибо за то , что посетили нашу выставку";
                string fromName = "Поддержка по отправке сообщение";

                findedExpoUser.DateOfVisiting = DateTime.Now;

                string mailMessage = await findedExpoUser.SendMessageAsync(subject, msg, fromName);

                _db.GetCollection <ExpoUser>("ExpoUser").Update(userId, findedExpoUser);
                statusCode = 0;
                message    = "Вы были активированы. " + mailMessage;
            }

            return(RedirectToAction("UserInfo", "User", new { statusCode, message }));
        }
Exemplo n.º 2
0
        public ActionResult Delete(Guid?userId)
        {
            if (userId == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            int      statusCode;
            string   message;
            ExpoUser findedExpoUser = _db.GetCollection <ExpoUser>("ExpoUser").FindById(userId);

            if (findedExpoUser == null)
            {
                return(HttpNotFound());
            }

            try
            {
                _db.GetCollection <ExpoUser>("ExpoUser").Delete(userId);
                statusCode = 0;
                message    = "Удаление прошло успешно";
            }
            catch (Exception e)
            {
                statusCode = 2;
                message    = e.ToString();
            }
            return(RedirectToAction("UserInfo", "User", new { statusCode, message }));
        }
Exemplo n.º 3
0
        public ActionResult Details(Guid?userId)
        {
            ExpoUser findedExpoUser = _db.GetCollection <ExpoUser>("ExpoUser").FindById(userId);

            if (findedExpoUser == null)
            {
                return(HttpNotFound());
            }
            return(View(findedExpoUser));
        }
Exemplo n.º 4
0
        public ActionResult UserRegistrationInfo(Guid?expoUserId)
        {
            if (expoUserId == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            ExpoUser expoUser = _db.GetCollection <ExpoUser>("ExpoUser").FindById(expoUserId);

            return(View(expoUser));
        }
Exemplo n.º 5
0
        public async Task <ActionResult> RegisterForm(ExpoUser expoUser)
        {
            int    statusCode;
            string message;

            if (ModelState.IsValid)
            {
                using (_db)
                {
                    try
                    {
                        string path;
                        LiteCollection <ExpoUser> liteCollection = _db.GetCollection <ExpoUser>("ExpoUser");
                        ExpoUser findedExpoUser = liteCollection.FindOne(f => f.UserName == expoUser.UserName && f.UserEmail == expoUser.UserEmail && f.UserPhoneNumber == expoUser.UserPhoneNumber);
                        if (findedExpoUser != null)
                        {
                            path = Server.MapPath("/Template/barcode-" + findedExpoUser.Id + ".gif");
                            if (!System.IO.File.Exists(path))
                            {
                                liteCollection.Delete(findedExpoUser.Id);
                            }
                            else
                            {
                                await findedExpoUser.SendMessageAsync(path);

                                return(RedirectToAction("UserRegistrationInfo", "User", new { expoUserId = findedExpoUser.Id }));
                            }
                        }
                        Guid userIdGuid = Guid.NewGuid();
                        expoUser.Id = userIdGuid;
                        expoUser.DateOfRegistration = DateTime.Now;
                        expoUser.DateOfVisiting     = null;
                        Barcode128 code2 = new Barcode128
                        {
                            CodeType         = Barcode.CODE128_UCC,
                            ChecksumText     = true,
                            GenerateChecksum = true,
                            StartStopText    = true,
                            Code             = userIdGuid.ToString()
                        };

                        System.Drawing.Bitmap bm2 = new System.Drawing.Bitmap(code2.CreateDrawingImage(System.Drawing.Color.Black, System.Drawing.Color.White));
                        path = Server.MapPath("/Template/barcode-" + expoUser.Id + ".gif");
                        bm2.Save(path, System.Drawing.Imaging.ImageFormat.Gif);

                        liteCollection.Insert(expoUser);
                        liteCollection.EnsureIndex(e => e.Id);
                        await expoUser.SendMessageAsync(path);

                        return(RedirectToAction("UserRegistrationInfo", "User", new { expoUserId = expoUser.Id }));
                    }
                    catch (Exception e)
                    {
                        statusCode = 2;
                        message    = e.ToString();
                    }
                }
            }
            else
            {
                statusCode = 1;
                message    = "Данные пришли пустыми";
            }
            return(RedirectToAction("Register", "User", new { statusCode, message }));
        }