Esempio n. 1
0
        public CreateTaskViewModel InitCreateTaskViewModelFromAnonymous()
        {
            var listFormatTypes = UoW.FORMAT_TYPE_Repository.Get(null, q => q.OrderBy(s => s.PK_ID_FORMAT_TYPE), "").ToList();

            var listFormat             = new FORMAT_Service().GetAll();
            var shortEditUserViewModel = new ShortEditUserViewModel();

            return(new CreateTaskViewModel
            {
                FK_ID_USER = 0,
                ListAvailableFormatTypes = listFormatTypes,
                ListAvailableFormats = listFormat,
                ShortEditUserViewModel = shortEditUserViewModel
            });
        }
        public ActionResult LoginAuto(ShortEditUserViewModel model)
        {
            model.Password = string.IsNullOrWhiteSpace(model.Password) ? "" : EncryptionUtil.Encrypt(model.Password);
            var user = new USER_Service().LoginUser(model.Username, model.Password);

            if (user != null)
            {
                SetCurrentUser(user.USERNAME, user.PK_ID_USER);

                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                return(View(model));
            }
        }
Esempio n. 3
0
        public CreateTaskViewModel InitCreateTaskViewModel(int userId)
        {
            var listFormatTypes = UoW.FORMAT_TYPE_Repository.Get(null, q => q.OrderBy(s => s.PK_ID_FORMAT_TYPE), "").ToList();

            var listFormat             = new FORMAT_Service().GetAll();
            var user                   = UoW.USER_Repository.GetByID(userId);
            var shortEditUserViewModel = new ShortEditUserViewModel(user);

            var         userTasks = GetListOfTaskByUserId(userId, false).Where(x => x.IS_PAID == false);
            TRANSACTION transaction;

            if (userTasks.Any())
            {
                transaction = userTasks.First().TRANSACTION;
            }
            else
            {
                transaction = new TRANSACTION
                {
                    DATE_TRANSACTION      = DateTime.Now,
                    FK_ID_USER            = userId,
                    PAYPAL_TRANSACTION_ID = DateTime.Now.Ticks,
                    PRICE = 0
                };
                UoW.TRANSACTION_Repository.Insert(transaction);
                UoW.Save();
            }

            return(new CreateTaskViewModel
            {
                FK_ID_USER = userId,
                ListAvailableFormatTypes = listFormatTypes,
                ListAvailableFormats = listFormat,
                ShortEditUserViewModel = shortEditUserViewModel,
                TransactionId = transaction.PK_ID_TRANSACTION
            });
        }