Exemple #1
0
        /// <summary>
        /// Save the user's track time data
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <IActionResult> SaveTrackTime(TrackTimeList input)
        {
            if (TempData.Peek("userName") == null)
            {
                return(UserNotAllowedAccess());
            }

            var workHourTrackerList = new WorkHourTrackerListResult()
            {
                Errors = new List <string>(), WorkHourTrackList = new List <dynamic>()
            };

            //get the start and end dates so we can display the track time details page when this operation is done
            string startOfWeek = input.UserTrackTimeList[0].StartDate;
            string lastOfWeek  = input.UserTrackTimeList[0].EndDate;

            //if the ModelState is invalid return the user to the CreateProject page and show them the validation errors
            if (!ModelState.IsValid)
            {
                List <string> errors = ModelState.Values.SelectMany(p => p.Errors.Select(x => x.ErrorMessage)).ToList();
                TempData.Add("SaveTrackTimeError", errors);
                return(RedirectToAction("DisplayTrackTimeDetails", "TrackTime", new { startDate = startOfWeek, endDate = lastOfWeek }));
            }

            try
            {
                //foreach record in the input list, save the new track time data
                foreach (var project in input.UserTrackTimeList)
                {
                    var saveTrackTimeInput =
                        new TrackTimeDatabaseInput(TempData.Peek("userGuid").ToString(), project.ProjectName,
                                                   project.HourSun, project.HourMon, project.HourTues, project.HourWed,
                                                   project.HourThurs, project.HourFri, project.HourSat, project.Comments,
                                                   project.StartDate, project.EndDate);

                    await _ITrackTimeDomain.InsertTrackTime(saveTrackTimeInput);
                }
            }
            catch (Exception)
            {
                throw;
            }
            workHourTrackerList.Errors.Add("TrackTime data has been saved!");
            TempData.Add("SaveTrackTime", workHourTrackerList.Errors);

            return(RedirectToAction("DisplayTrackTimeDetails", "TrackTime", new { startDate = startOfWeek, endDate = lastOfWeek }));
        }
Exemple #2
0
        public ActionResult modeltest()
        {
            var obj = new SampleObject
            {
                Name  = "david",
                Phone = "0987654321",
            };
            var json = JsonConvert.SerializeObject(obj, Formatting.None);



            //response
            var cookie = new HttpCookie("name");

            cookie.Value    = "my_cookie_is_here";
            cookie.HttpOnly = true;
            cookie.Expires  = DateTime.Now.AddMinutes(3);
            Response.Cookies.Add(cookie);
            //request
            cookie = Request.Cookies["name"];



            var app = Request.RequestContext.HttpContext.Application;

            //get app state value
            app.Get("key");
            app.Set("key", "value");
            app.Remove("key");
            app.Clear();



            //ViewDataDictionary
            ViewData.Add("data", "0001"); //using viewdata to store data
            //ViewBag
            ViewBag.DataC = "0002";       //the storage source is the same as view data
            //TempData
            TempData.Add("data", "0003"); //using Session to store data


            ViewBag.HtmlData = "<h3>Raw Data</h3>";



            return(PartialView(obj));
        }
        public ActionResult Add(Task task, FormCollection form)
        {
            bool isNew = false;

            if (task.ID == 0)
            {
                isNew = true;
            }

            task.AssignedByID = _membershipService.GetCurrentMember().UserId;
            task.Body         = Helpers.HtmlHelper.CleanHtml(form["Body"]);

            //assign the task to a user
            if (!string.IsNullOrEmpty(form["Members"]))
            {
                task.AssignedID = Convert.ToInt32(form["Members"].ToString());
            }

            //assign areatype (either sale or lead)
            if (!string.IsNullOrEmpty(form["AreaType"]))
            {
                task.AreaType = (AreaType)Convert.ToInt32(form["AreaType"]);
            }

            //assign itemid of the above areatype
            if (!string.IsNullOrEmpty(form["ItemID"]))
            {
                task.ItemID = System.Convert.ToInt32(form["ItemID"]);
            }

            //assign its action type; lead, sale, contact...
            if (!string.IsNullOrEmpty(form["AreaType"]))
            {
                ViewData.SelectListEnumViewData <ActionType>("ActionType", true);
            }

            _taskService.Save(task);

            //write activity to the log
            if (isNew)
            {
                _activityService.Create("was added", AreaType.Task, User.Identity.Name, task.ID);
            }

            TempData.Add("StatusMessage", "Task added");
            return(RedirectToAction("Index"));
        }
        public ActionResult Create(CreateTransactionViewModel transactionViewModel)
        {
            if (!ModelState.IsValid || transactionViewModel.BankAccountId is null || transactionViewModel.CategoryId is null)
            {
                TransactionHelpers.SetDropDownLists(transactionViewModel, Request);

                if (TransactionHelpers.BankAccntOrCategoriesIsNull(transactionViewModel, TempData))
                {
                    return(RedirectToAction("Index", "Household"));
                }

                return(View(transactionViewModel));
            }


            var url = $"{ProjectConstants.APIURL}/api/transaction/create/{transactionViewModel.BankAccountId}";

            var parameters = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("Title", transactionViewModel.Title),
                new KeyValuePair <string, string>("Description", transactionViewModel.Description),
                new KeyValuePair <string, string>("Amount", transactionViewModel.Amount.ToString()),
                new KeyValuePair <string, string>("Date", transactionViewModel.Date.ToString()),
                new KeyValuePair <string, string>("CategoryId", transactionViewModel.CategoryId.ToString()),
            };

            var encodedParameters = new FormUrlEncodedContent(parameters);
            var response          = HttpClientContext.httpClient.PostAsync(url, encodedParameters).Result;

            if (response.IsSuccessStatusCode)
            {
                TempData.Add("Message", "Transaction Created!");
                return(RedirectToAction("HouseholdTransactions", "Transaction", new { Id = transactionViewModel.HouseholdId }));
            }
            else
            {
                TransactionHelpers.SetDropDownLists(transactionViewModel, Request);
                if (TransactionHelpers.BankAccntOrCategoriesIsNull(transactionViewModel, TempData))
                {
                    return(RedirectToAction("Index", "Household"));
                }

                ErrorHelpers.HandleResponseErrors(response, TempData, ModelState);

                return(View(transactionViewModel));
            }
        }
        public ActionResult TakeOwnership(TakeOwnerShipModel model)
        {
            try
            {
                if (!Request.IsAuthenticated)
                {
                    RedirectToAction("Login");
                }

                if (!ModelState.IsValid)
                {
                    // If we got this far, something failed, redisplay form
                    return(View(model));
                }

                _accountBusinessLogic.ValidateOwner(model);
                var validPasscode = _accountBusinessLogic.ValidatePasscode(model);

                if (!validPasscode)
                {
                    throw new ApplicationException("Pass Code is not correct");
                }

                if (TempData.ContainsKey("passcode"))
                {
                    TempData["passcode"] = model.PassCode;
                }
                else
                {
                    TempData.Add("passcode", model.PassCode);
                }
                return(RedirectToAction("Register"));
            }
            catch (Exception ex)
            {
                _log.ErrorFormat(
                    "Current User: {0} - An exception occurred with TakeOwnership Passcode: {1}",
                    User.Identity.Name,
                    ex.Message);
                _applicationAlert.RaiseAlert(ApplicationAlertKind.System, ex.TraceInformation());

                ModelState.AddModelError("Error", ex.Message);
                TempData.Remove("ownershipError");
                TempData["ownershipError"] = ex.Message;
                return(View(model));
            }
        }
Exemple #6
0
        public async Task <IActionResult> OrderDetails(int orderId)
        {
            var sessState = _session.GetString("_sessionState");


            if (string.IsNullOrEmpty(sessState) || sessState != "valid")
            {
                return(RedirectToAction("Index", new { orderId = orderId }));
            }

            OrderSummaryDto orderSummary = null;

            try
            {
                orderSummary = await _viewModel.GetOrderSummaryAsync(orderId);



                if (orderSummary == null)
                {
                    TempData.Add("Message", "Order not found");
                    return(RedirectToAction("Error"));
                }

                if (orderSummary.Status == "PAID")
                {
                    TempData.Add("Message", "Order has already been paid for");
                    return(RedirectToAction("Error"));
                }


                await _viewModel.UpdateOrderStatusAsync(orderId, "viewed");
            }
            catch (Exception ex)
            {
                TempData.Add("Message", ex.Message);
                return(RedirectToAction("Error"));
            }

            ViewBag.OrderSummary = orderSummary;


            return(View(new PaymentDto()
            {
                OrderId = orderId
            }));
        }
Exemple #7
0
        public ActionResult SavePassword(User userDetails)
        {
            ApiResponse response          = new ApiResponse();
            User        authenticatedUser = new User();

            if (userDetails != null && userDetails.EmailId != null &&
                userDetails.PhoneNumber != null &&
                !string.IsNullOrEmpty(userDetails.Password) &&
                !string.IsNullOrEmpty(userDetails.ConfirmPassword))

            {
                if (userDetails.Password.Equals(userDetails.ConfirmPassword))
                {
                    response = WebApiClientUtility.Post <User>("users", userDetails, 0, "SavePassword").Result;
                    if (response != null && response.Result != null)
                    {
                        authenticatedUser = JsonConvert.DeserializeObject <User>(response.Result.ToString());
                    }

                    if (authenticatedUser != null && authenticatedUser.UserId != 0)
                    {
                        if (TempData != null && TempData.ContainsKey("AuthenticatedUser"))
                        {
                            TempData.Remove("AuthenticatedUser");
                        }
                        else
                        {
                            TempData.Add("AuthenticatedUser", authenticatedUser);
                        }

                        return(RedirectToAction("Index", "Dashboard"));
                    }
                    else
                    {
                        return(RedirectToAction("UnAuthorizedLogin"));
                    }
                }
                else
                {
                    return(RedirectToAction("UnAuthorizedLogin"));
                }
            }
            else
            {
                return(RedirectToAction("UnAuthorizedLogin"));
            }
        }
        public async Task <ActionResult> ChangeCreditCard(CreditCardViewModel model)
        {
            var userId = User.Identity.GetUserId();

            if (ModelState.IsValid && await CardService.CardBelongToUser(model.CreditCard.Id, userId))
            {
                var user = await UserManager.FindByIdAsync(userId);

                await CardService.UpdateAsync(user, model.CreditCard);

                TempData.Add("flash", new FlashSuccessViewModel("Your credit card has been updated successfully."));

                return(RedirectToAction("Index"));
            }

            return(View(model));
        }
        public async Task <ActionResult> ReActivateSubscription()
        {
            var currentSubscription = (await SubscriptionsFacade.UserActiveSubscriptionsAsync(User.Identity.GetUserId())).FirstOrDefault();
            var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());

            if (currentSubscription != null &&
                await SubscriptionsFacade.UpdateSubscriptionAsync(user.Id, user.StripeCustomerId, currentSubscription.SubscriptionPlanId))
            {
                TempData.Add("flash", new FlashSuccessViewModel("Your subscription plan has been re-activated."));
            }
            else
            {
                TempData.Add("flash", new FlashDangerViewModel("Ooops! There was a problem re-activating your subscription. Please, try again."));
            }

            return(RedirectToAction("Index"));
        }
        private async Task Update_Encounter_Stats_BurstOnly()
        {
            var encList = await _encounterRepository.GetEncountersMissingBurstStatistics(15000);

            _logger.Debug($"Found {encList.Count} encounters missing burst statistics");
            // Optionally filter our list for a specific bossfight here for testing
            //encList = encList.Where(e => e.BossFightId == 129).ToList();
            //_logger.Debug($"Updating stats for a filtered set of {encList.Count} encounters");

            Stopwatch sw = new Stopwatch();

            for (var i = 1; i <= encList.Count; i++)
            {
                sw.Restart();
                var enc        = encList[i - 1];
                var maxSeconds = Convert.ToInt32(Math.Floor(enc.Duration.TotalSeconds));

                var dmgRecords = await _encounterRepository.GetAllDamageDoneForEncounterAsync(enc.Id);

                var healRecords = await _encounterRepository.GetAllHealingDoneForEncounterAsync(enc.Id);

                var shieldRecords = await _encounterRepository.GetAllShieldingDoneForEncounterAsync(enc.Id);

                var recordTimer = sw.Elapsed.ToString();
                sw.Restart();
                var burstRecords = await BurstCalculator.CalculateBurst(dmgRecords, healRecords, shieldRecords, enc.Id, maxSeconds);

                var calcTimer = sw.Elapsed.ToString();
                sw.Restart();
                // Perform the update
                var updateResult = await _encounterRepository.UpdateEncounterBurstStatistics(burstRecords);

                sw.Stop();
                if (updateResult.Success)
                {
                    _logger.Debug(
                        $"Encounter {enc.Id} burst updated. Records in {recordTimer}, calc in {calcTimer}, updated in {sw.Elapsed}");
                }
                else
                {
                    _logger.Debug($"Encounter {enc.Id} burst update failed: {updateResult.Message}");
                }
            }

            TempData.Add("flash", new FlashSuccessViewModel("Update_Encounter_Stats_BurstOnly() complete!"));
        }
        public async Task <IActionResult> OnPost()
        {
            string user, pass;

            try
            {
                (user, pass) = loginProvider.GetLoginInfo();
            }
            catch (Exception ex)
            {
                logger.LogCritical(ex.Message);
                Response.StatusCode = 500;
                return(Content(ex.Message));
            }



            if (String.Compare(UserName, user, false) == 0 && String.Compare(Password, pass, false) == 0)
            {
                //login successful

                var claims = new List <Claim>();
                claims.Add(new Claim(ClaimTypes.NameIdentifier, UserName));
                claims.Add(new Claim(ClaimTypes.Name, UserName));


                var claimsIdentity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme);
                var authProperties = new AuthenticationProperties()
                {
                    ExpiresUtc   = DateTimeOffset.UtcNow.AddDays(30),
                    IsPersistent = true
                };

                await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(claimsIdentity), authProperties);

                logger.LogInformation("{0} logged in.", UserName);

                return(new RedirectToPageResult("Index"));
            }
            else
            {
                //login failed
                TempData.Add("error", "UserName and Password do not match!");
                return(Page());
            }
        }
 //Delete
 #region
 // GET: films/Delete/5
 public ActionResult Delete(int?id)
 {
     try
     {
         ManagerFilm m = new ManagerFilm();
         film        f = m.GetFilm(id);
         if (f != null)
         {
             return(PartialView("PartialDelete", f));
         }
     }
     catch (Exception e)
     {
         TempData.Add("Alert", e.Message);
     }
     return(RedirectToAction("Index"));
 }
        public ActionResult DeleteCart(string id = "")
        {
            if (id == "")
            {
                return(Redirect("~/cart"));
            }
            if (TempData.Peek("cart") == null)
            {
                return(Redirect("~/cart"));
            }
            List <Cart> ListCart = (List <Cart>)TempData.Peek("cart");

            ListCart.RemoveAll(c => c.GetProduct().ProductId.Equals(id));
            TempData.Add("message", "Product by id " + id + " deleted succesfully");
            TempData.Add("type", "danger");
            return(Redirect("~/cart"));
        }
Exemple #14
0
        public ActionResult Create(int?Id)
        {
            // Household Id
            if (Id is null)
            {
                TempData.Add("Message", "Improper Id");
                TempData.Add("MessageColour", "danger");
                return(RedirectToAction("Index", "Household"));
            }

            var viewModel = new CreateBankAccountViewModel()
            {
                HouseholdId = (int)Id
            };

            return(View(viewModel));
        }
        public ActionResult Login(LoginViewModel model, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            UserManager  usrBL      = new UserManager();
            UserDetailDO userDetail = usrBL.AuthenticateUser(model.UserName, model.Password);

            if (userDetail != null)
            {
                Session["user"] = userDetail; FormsAuthentication.SetAuthCookie(userDetail.UserName.ToString(), true); return(RedirectToLocal(returnUrl));
            }
            TempData.Add("Error", "Incorrect UserName or Password");
            return(View(new LoginViewModel()));
        }
        public ActionResult Register(UserDetailDO postedForm)
        {
            if (!ModelState.IsValid)
            {
                TempData.Add("Message", "Registration Failed"); return(View(new UserDetailDO()));
            }
            UserManager usrMngr = new UserManager();

            if (usrMngr.RegisterUser(postedForm))
            {
                TempData.Add("Message", "Registration Success, Login again to proceed."); return(RedirectToAction("Login"));
            }
            else
            {
                TempData.Add("Message", "Registration Failed"); return(View());
            }
        }
        public ActionResult HouseholdTransactions(int?Id)
        {
            if (Id is null)
            {
                TempData.Add("Message", "Improper Id");
                TempData.Add("MessageColour", "danger");
                return(RedirectToAction("Index", "Household"));
            }

            var url = $"{ProjectConstants.APIURL}/api/transaction/getallbyhousehold/{Id}";

            var token      = Request.Cookies["UserAuthCookie"].Value;
            var authHeader = new AuthenticationHeaderValue("Bearer", token);

            HttpClientContext.httpClient.DefaultRequestHeaders.Authorization = authHeader;

            // Handling lack of connection??? try catch?
            var response = HttpClientContext.httpClient.GetAsync(url).Result;

            if (response.IsSuccessStatusCode)
            {
                var responseResult = response.Content.ReadAsStringAsync().Result;

                var datas = JsonConvert.DeserializeObject <List <TransactionViewModel> >(responseResult);

                foreach (var item in datas)
                {
                    item.CategoryName    = HouseholdHelpers.GetCategoryName(item.CategoryId, Request);
                    item.BankAccountName = HouseholdHelpers.GetBankAccountName(item.BankAccountId, Request);
                    item.UserCanEdit     = TransactionHelpers.IsUserCreator(item.Id, Request, TempData);
                }

                var viewModel = new TransactionListViewModel
                {
                    Transactions             = datas,
                    HouseholdId              = (int)Id,
                    IsHouseholdOwnerOrMember = HouseholdHelpers.IsUserCreatorOrMember((int)Id, Request, TempData)
                };
                return(View(viewModel));
            }
            else
            {
                ErrorHelpers.HandleResponseErrors(response, TempData, ModelState);
                return(RedirectToAction("Index", "Household"));
            }
        }
        public async Task <ActionResult> Index(Beer model)
        {
            Guid?cartID = this.GetCartID();
            Cart cart   = null;

            if (cartID.HasValue)
            {
                cart = await db.Carts.FindAsync(cartID);
            }
            if (cart == null)
            {
                cartID = Guid.NewGuid();
                cart   = new Cart
                {
                    ID               = cartID.Value,
                    DateCreated      = DateTime.UtcNow,
                    DateLastModified = DateTime.UtcNow
                };
                db.Carts.Add(cart);
                Response.AppendCookie(new HttpCookie(CartHelper.CartID, cartID.ToString()));
            }

            CartProduct product = cart.CartProducts.FirstOrDefault(x => x.ProductID == model.BeerID);

            if (product == null)
            {
                product = new CartProduct
                {
                    DateCreated      = DateTime.UtcNow,
                    DateLastModified = DateTime.UtcNow,
                    ProductID        = model.BeerID,
                    Quantity         = 0
                };
                cart.CartProducts.Add(product);
            }

            product.Quantity        += model.Quantity ?? 1;
            product.DateLastModified = DateTime.UtcNow;
            cart.DateLastModified    = DateTime.UtcNow;

            await db.SaveChangesAsync();

            TempData.Add("NewItem", model.Name);

            return(RedirectToAction("Index", "Cart"));
        }
Exemple #19
0
        public ActionResult RegisterForSlack()
        {
            var result = string.Empty;

            //string URI = string.Format(Properties.Settings.Default.SlackInviteURL, UserManager.FindById(User.Identity.GetUserId()).EmailAddress, Properties.Settings.Default.SlackToken);
            //using(WebClient client = new WebClient())
            //{
            //    byte[] response = client.DownloadData(URI);
            //    result = System.Text.Encoding.UTF8.GetString(response);
            //}

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(string.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Authority, Url.Content("~")));
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                try
                {
                    var task = Task.Factory.StartNew(() => JsonConvert.DeserializeObject <string>(client.GetStringAsync(string.Format("api/SlackRegistry/r3mus/{0}/{1}",
                                                                                                                                      UserManager.FindById(User.Identity.GetUserId()).EmailAddress,
                                                                                                                                      Properties.Settings.Default.SlackToken
                                                                                                                                      )).Result));
                    task.Wait();
                    result = task.Result;
                }
                catch (Exception ex)
                {
                    result = string.Format("false:{0}", ex.Message);
                }
            }

            if (result.Contains("false"))
            {
                TempData.Add("Message", string.Format("Could not send an invitation: {0}", result));
            }
            else if (result.Contains("true"))
            {
                TempData.Add("Message", string.Format("Slack invitation sent to {0}; please check your email inbox.", UserManager.FindById(User.Identity.GetUserId()).EmailAddress));
            }
            else
            {
                TempData.Add("Message", string.Format("Could not send an invitation: unknown reason."));
            }
            return(RedirectToAction("Index"));
        }
        public async Task <IActionResult> UpdatePublishedVacancy(ProposedChangesEditModel m)
        {
            var response = await _orchestrator.UpdatePublishedVacancyAsync(m, User.ToVacancyUser());

            if (!response.Success)
            {
                return(RedirectToRoute(RouteNames.VacancyEditDates_Get));
            }

            var vacancy = await _orchestrator.GetVacancy(m);

            TempData.Add(TempDataKeys.VacanciesInfoMessage, string.Format(InfoMsg.VacancyUpdated, vacancy.Title));

            EnsureProposedChangesCookiesAreCleared(m.VacancyId.GetValueOrDefault());

            return(RedirectToRoute(RouteNames.Vacancies_Get));
        }
        public ActionResult Delete(int id)
        {
            
            try
            {
                resCrud.DeleteRestaurantById(id);
            }
            catch (NullReferenceException e) 
            {
                Logger log = LogManager.GetCurrentClassLogger();
                log.Info(e.Message);
                TempData.Add("error", e.Message);
                

            }
            return RedirectToAction("index");
        }
Exemple #22
0
 public ActionResult RemindMeLaterClick(string Command)
 {
     BXGOwner = (BGO.OwnerWS.Owner)Session["BXGOwner"];
     if (ModelState.IsValid)
     {
         //redirect to current page to clear the form
         TempData.Add("DisplayReminderButtons", false);
         RenewalMsgPopup(Constants.SavePointsRemindme);
         string path = BGModern.HtmlExtensions.CustomHtmlHelpers.GetFullSitePath(null).ToString();
         return(Redirect(path + "/Home"));
     }
     else
     {
         //Add Error processing here
         return(CurrentUmbracoPage());
     }
 }
        public IActionResult Sil(int?id)
        {
            var productsSellerId   = _productService.GetById((int)id).SellerId;
            var authorizedSellerId = _usersAndSellersService.GetByUserId(_userManager.GetUserId(User)).SellerId;

            if (productsSellerId != authorizedSellerId)
            {
                return(NotFound());
            }
            if (id == null)
            {
                return(NotFound());
            }
            _productService.Delete((int)id);
            TempData.Add("message", "Ürününüz başarıyla silindi.");
            return(RedirectToAction("Urunlerim", "Profil"));
        }
Exemple #24
0
        public ActionResult SendPost(SendPostViewModel viewModel)
        {
            if (viewModel.Content == null || !_postValidator.IsValid(viewModel.Content))
            {
                TempData.Add("SendPostContent", viewModel.Content);
                TempData.Add("SendPostError", "The post has invalid content.");
            }
            else if (_topicService.ValidateTopicAndCategoryAlias(viewModel.TopicAlias, viewModel.CategoryAlias))
            {
                var postDTO = Mapper.Map <NewPostDTO>(viewModel);
                postDTO.AuthorID = _authService.GetCurrentUser().ID;

                _topicService.AddPost(viewModel.TopicAlias, postDTO);
            }

            return(RedirectToAction("Index", new { categoryAlias = viewModel.CategoryAlias, topicAlias = viewModel.TopicAlias }));
        }
Exemple #25
0
        public ActionResult SaveExcel()
        {
            try
            {
                var reportRead = ServiceLocator.Instance.Resolve <IReportRead>();
                var fileName   = reportRead.TableOrViewName;
                var fileBytes  = reportRead.ExecuteExcelExport(fileName);
                TempData.Add(ExcelName, fileName);
                TempData.Add(ExcelKey, fileBytes);

                return(Json(true));
            }
            catch (Exception)
            {
                return(Json(false));
            }
        }
Exemple #26
0
        private void SetCouponData()
        {
            if (Session["guid"] == null)
            {
                Session.Add("guid", Guid.NewGuid().ToString());
            }

            var pin  = ((string)Session["guid"]);
            var code = 102270;

            if (!TempData.ContainsKey("coupon"))
            {
                TempData.Add("coupon",
                             "http://bricks.coupons.com/enable.asp?o=" + code + "&c=PR&p=" + pin + "&cpt=" +
                             CouponEncode.EncodeCPT(pin, code));
            }
        }
Exemple #27
0
        public IActionResult Create(Category category)
        {
            var categoryList  = _categoryService.GetCategories();
            var categoryToAdd = categoryList.Find(x => x.Name == category.Name);

            if (categoryToAdd != null)
            {
                TempData.Add("message", category.Name + " kategorisi zaten mevcut!");
                return(RedirectToAction("ItemList", "Item"));
            }
            else
            {
                _categoryService.Add(category);
                TempData.Add("message", category.Name + " kategorisi eklendi.");
            }
            return(RedirectToAction("ItemList", "Item"));
        }
Exemple #28
0
        public ActionResult Index(bool?solutionSubmitted)
        {
            if (solutionSubmitted.HasValue && solutionSubmitted.Value)
            {
                TempData.Add("solutionSubmitted", true);
            }

            var problemsViewModel = (from problems in EntitiesContext.Problems
                                     select new ProblemViewModel
            {
                Id = problems.Id,
                Identifier = problems.Identifier,
                Name = problems.Name
            }).ToList();

            return(View(problemsViewModel));
        }
        public async Task <ActionResult> UserRoles(int id, AddRoleViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var user = await UserManager.FindByIdAsync(id);

                    TempData.Add(GlobalTypes.Message, new AlertResult(AlertStatusId.Success, "Kayıt güncelleme işlemi başarıyla gerçekleştirildi."));
                }
            }
            catch (Exception)
            {
                TempData.Add(GlobalTypes.Message, new AlertResult(AlertStatusId.Error, "Hata", "İşlem sırasında hata oluştu. Lütfen Daha sonra tekrar deneyiniz."));
            }
            return(View(model));
        }
        public async Task <ActionResult> ChangeSubscription(ChangeSubscriptionViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());

                await SubscriptionsFacade.UpdateSubscriptionAsync(user.Id, user.StripeCustomerId, model.NewPlan);

                TempData.Add("flash", new FlashSuccessViewModel("Your subscription plan has been updated."));
            }
            else
            {
                TempData.Add("flash", new FlashSuccessViewModel("Sorry, there was an error updating your plan, try again or contact support."));
            }

            return(RedirectToAction("Index"));
        }