//check if Serial No already exist in database public JsonResult IsSerialAvailable(string TermainlSerial, int TerminalId = 0) { if (!String.IsNullOrEmpty(TermainlSerial)) { TermainlSerial = TermainlSerial.Trim(); } // get properties of tenant caTenant tenant = caCurrent.CurrentTenant(); int result = 0; if (TerminalId == 0) { result = _terminalServices.GetTerminalCountBySerial(TermainlSerial, tenant.TenantId); } else { result = _terminalServices.GetTerminalCountBySerialNotEqualId(TermainlSerial, TerminalId, tenant.TenantId); } if (result > 0) { return(Json(false, JsonRequestBehavior.AllowGet)); } else { return(Json(true, JsonRequestBehavior.AllowGet)); } }
// GET: Terminals/Edit/5 public ActionResult Edit(int?id) { if (!caSession.AuthoriseSession()) { return(Redirect((string)Session["ErrorUrl"])); } // get properties of tenant caTenant tenant = caCurrent.CurrentTenant(); // get current warehouse TenantLocations Warehouse = caCurrent.CurrentWarehouse(); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Terminals terminals = _terminalServices.GetTerminalById((int)id); if (terminals == null) { return(HttpNotFound()); } ViewBag.WarehouseId = new SelectList(_tenantLocationServices.GetTenantLocationListById(Warehouse.WarehouseId, tenant.TenantId), "WarehouseId", "WarehouseName", terminals.WarehouseId); return(View(terminals)); }
public ActionResult Edit(TenantLocations tenantwarehouse) { if (ModelState.IsValid) { // get properties of tenant caTenant tenant = caCurrent.CurrentTenant(); // get properties of user caUser user = caCurrent.CurrentUser(); _tenantLocationServices.UpdateTenantLocation(tenantwarehouse, user.UserId, tenant.TenantId); return(RedirectToAction("Index")); } ViewBag.TenantLocations = LookupServices.GetAllWarehousesForTenant(CurrentTenantId, (int)tenantwarehouse.TenantId); ViewBag.AllTerminals = _terminalServices.GetAllTerminalsWithoutMobileLocationLinks(CurrentTenantId, tenantwarehouse.SalesTerminalId).Select(m => new SelectListItem() { Value = m.TerminalId.ToString(), Text = m.TerminalName + " " + m.TermainlSerial }); ViewBag.AllDrivers = _employeeServices.GetAllEmployeesWithoutResourceLinks(CurrentTenantId, tenantwarehouse.SalesManUserId).Select(m => new SelectListItem() { Value = m.AuthUserId.ToString(), Text = m.SurName + " " + m.FirstName }); return(View(tenantwarehouse)); }
public JsonResult Delete(int Id) { if (!caSession.AuthoriseSession()) { return(Json(new { success = false })); } // get properties of tenant caTenant tenant = caCurrent.CurrentTenant(); // get properties of user caUser user = caCurrent.CurrentUser(); try { _groupsServices.Delete(Mapper.Map <Groups>(new GroupsViewModel { Id = Id }), CurrentUserId); return(Json(new { success = true })); } catch (Exception e) { //catch error here var err = e.Message; } return(Json(new { success = false })); }
public ActionResult Edit([Bind(Include = "TerminalId,TerminalName,TermainlSerial,WarehouseId,IsActive")] Terminals terminals) { // get properties of tenant caTenant tenant = caCurrent.CurrentTenant(); // get properties of user caUser user = caCurrent.CurrentUser(); // get current warehouse TenantLocations Warehouse = caCurrent.CurrentWarehouse(); if (ModelState.IsValid) { Terminals newTerminal = _terminalServices.GetTerminalById(terminals.TerminalId); newTerminal.TerminalName = terminals.TerminalName; newTerminal.TermainlSerial = terminals.TermainlSerial; newTerminal.WarehouseId = terminals.WarehouseId; newTerminal.IsActive = terminals.IsActive; _terminalServices.UpdateTerminal(newTerminal, user.UserId, tenant.TenantId); return(RedirectToAction("Index")); } ViewBag.WarehouseId = new SelectList(_tenantLocationServices.GetTenantLocationListById(Warehouse.WarehouseId, tenant.TenantId), "WarehouseId", "WarehouseName", terminals.WarehouseId); return(View(terminals)); }
public ActionResult Details(int id, string message = "") { if (!caSession.AuthoriseSession()) { return(Redirect((string)Session["ErrorUrl"])); } // get properties of tenant caTenant tenant = caCurrent.CurrentTenant(); // get properties of user caUser user = caCurrent.CurrentUser(); try { if (!String.IsNullOrWhiteSpace(message)) { ViewBag.Message = message; } var result = _groupsServices.GetByGroupsId(id); return(View("_CreateEdit", Mapper.Map(result, new GroupsViewModel()))); } catch (Exception e) { //log exception var err = e.Message; return(View("_EmptyResult")); } }
public ActionResult Submit(GroupsViewModel groups) { if (!caSession.AuthoriseSession()) { return(Redirect((string)Session["ErrorUrl"])); } // get properties of tenant caTenant tenant = caCurrent.CurrentTenant(); // get properties of user caUser user = caCurrent.CurrentUser(); try { if (ModelState.IsValid) { if (groups.Id <= 0) { groups.TenantId = tenant.TenantId; groups.DateCreated = DateTime.UtcNow; groups.DateUpdated = DateTime.UtcNow; groups.CreatedBy = user.UserId; groups.UpdatedBy = user.UserId; //insert groups.Id = _groupsServices.Insert(Mapper.Map <Groups>(groups), CurrentUserId); ViewBag.Message = $"Successfully Added on {DateTime.Now}."; } else { //update Groups newGroup = _groupsServices.GetByGroupsId(groups.Id); //groups.TenantId = Tenant.TenantId; newGroup.GroupName = groups.GroupName; newGroup.DateUpdated = DateTime.UtcNow; newGroup.UpdatedBy = user.UserId; _groupsServices.Update(Mapper.Map <Groups>(newGroup), CurrentUserId); ViewBag.Message = $"Successfully Updated on {DateTime.Now}."; } return(RedirectToAction("Index", new { message = ViewBag.Message })); } else //ModelState.IsValid is not valid { return(View("_CreateEdit", Mapper.Map(_groupsServices.GetByGroupsId(groups.Id), new GroupsViewModel()))); } } catch (Exception e) { //log exception var err = e.Message; return(View("_ErrorResult")); } }
public ActionResult _UserList() { // get properties of tenant caTenant tenant = caCurrent.CurrentTenant(); var model = _userService.GetAllAuthUsersForGrid(tenant.TenantId); return(PartialView("__UserList", model)); }
public ActionResult _Whouse() { // get properties of tenant caTenant tenant = caCurrent.CurrentTenant(); var model = _tenantLocationServices.GetAllTenantLocations(tenant.TenantId); return(PartialView("__Whouse", model.ToList())); }
public ActionResult _TenantList() { // get properties of tenant caTenant tenant = caCurrent.CurrentTenant(); var model = _tenantServices.GetAllClients(tenant.TenantId).ToList();; return(PartialView("__TenantList", model)); }
// GET: /TenantEmailConfig/ public ActionResult Index() { if (!caSession.AuthoriseSession()) { return(Redirect((string)Session["ErrorUrl"])); } // get properties of tenant caTenant tenant = caCurrent.CurrentTenant(); return(View(_tenantEmailConfigService.GetAllEmialConfigByTenant(tenant.TenantId))); }
public ActionResult DeleteConfirmed(int id) { AuthActivityGroupMap authactivitygroupmap = _activityServices.GetActivityGroupMapById((int)id); // get properties of tenant caTenant tenant = caCurrent.CurrentTenant(); // get properties of user caUser user = caCurrent.CurrentUser(); _activityServices.DeleteActivityGroupMap(authactivitygroupmap, user.UserId); return(RedirectToAction("Index")); }
public ActionResult Create(int?Id, string pageToken) { if (!caSession.AuthoriseSession()) { return(Redirect((string)Session["ErrorUrl"])); } caTenant tenant = caCurrent.CurrentTenant(); if (Id == null) { int ids = 0; var accountaddress = _accountServices.GetAllValidAccountContactsByAccountId(ids, CurrentTenantId); ViewBag.AccountContactes = new SelectList(accountaddress, "AccountContactId", "ContactEmail", accountaddress.Select(x => x.AccountID).FirstOrDefault()); Order NewOrder = new Order(); NewOrder.OrderNumber = GeneratePO(); NewOrder.IssueDate = DateTime.Today; SetViewBagItems(tenant, EnumAccountType.Customer); ViewBag.AccountContacts = new SelectList( AccountServices.GetAllTopAccountContactsByTenantId(CurrentTenantId), "AccountContactId", "ContactName"); ViewBag.OrderDetails = new List <OrderDetail>(); ViewBag.OrderProcesses = new List <OrderProcess>(); ViewBag.IsShipmentToAccountAddress = true; ViewBag.AccountAddresses = new List <SelectListItem>() { new SelectListItem() { Text = "Select", Value = "0" } }; ViewBag.ShipmentAccountAddressId = 0; ViewBag.IsShipmentToCustomAddress = false; ViewBag.ConsignmentTypes = new SelectList(OrderService.GetAllValidConsignmentTypes(CurrentTenantId), "ConsignmentTypeId", "ConsignmentType"); if (string.IsNullOrEmpty(pageToken)) { ViewBag.ForceRegeneratePageToken = "True"; ViewBag.ForceRegeneratedPageToken = Guid.NewGuid().ToString(); } else { ViewBag.ForceRegeneratePageToken = "False"; ViewBag.ForceRegeneratedPageToken = pageToken; } return(View(NewOrder)); } return(View()); }
public ActionResult Edit([Bind(Include = "ActivityGroupId,ActivityGroupName,ActivityGroupDetail,IsActive")] AuthActivityGroup authactivitygroup) { if (ModelState.IsValid) { // get properties of tenant caTenant tenant = caCurrent.CurrentTenant(); // get properties of user caUser user = caCurrent.CurrentUser(); _activityServices.UpdateActivityGroup(authactivitygroup, user.UserId, tenant.TenantId); return(RedirectToAction("Index")); } return(View(authactivitygroup)); }
public ActionResult Create(string delivery = "", int id = 0, int receivepo = 0) { /// Authorization Check if (!caSession.AuthoriseSession()) { return(Redirect((string)Session["ErrorUrl"])); } // get properties of tenant caTenant tenant = caCurrent.CurrentTenant(); if (id == 0) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } //find PO of given id Order NewOrder = OrderService.GetOrderById(id); if (NewOrder == null) { return(HttpNotFound()); } //1 get all podetail of given po var podetail = NewOrder.OrderDetails.Where(x => x.WarehouseId == CurrentWarehouseId && x.IsDeleted != true); // 2 get all receive po detail //var receivepodetail = po.ReceivePOs.Select(x=>x.ReceivePODetails); var receivepodetail = NewOrder.OrderProcess.Where(x => x.WarehouseId == CurrentWarehouseId && x.IsDeleted != true).Select(x => x.OrderProcessID); //declare list of objects for view List <OrderProcessDetail> ReceivePOLine = new List <OrderProcessDetail>(); foreach (var item in podetail) { //////////// // create ReceivePOLine object /////////////////////////////// OrderProcessDetail line = new OrderProcessDetail(); //assigning values line.OrderProcessDetailID = item.OrderDetailID; line.ProductId = item.ProductId; line.QtyProcessed = OrderService.GetAllOrderProcessesByOrderDetailId(item.OrderDetailID, CurrentWarehouseId).Sum(x => (decimal?)x.QtyProcessed) ?? 0; } // end of loop ViewBag.rpodetail = ReceivePOLine; ViewBag.RPO = receivepo; ViewBag.delivery = delivery; return(View(NewOrder)); }
public ActionResult Create([Bind(Include = "ActivityName,ActivityController,ActivityAction,IsActive,ExcludePermission,RightNav")] AuthActivity authactivity) { if (ModelState.IsValid) { // get properties of tenant caTenant tenant = caCurrent.CurrentTenant(); // get properties of user caUser user = caCurrent.CurrentUser(); _activityServices.SaveActivity(authactivity, user.UserId, tenant.TenantId); return(RedirectToAction("Index")); } return(View(authactivity)); }
public ActionResult Edit([Bind(Include = "ActivityGroupMapId,ActivityId,ActivityGroupId,IsActive")] AuthActivityGroupMap authactivitygroupmap) { if (ModelState.IsValid) { caTenant tenant = caCurrent.CurrentTenant(); // get properties of user caUser user = caCurrent.CurrentUser(); _activityServices.UpdateActivityGroupMap(authactivitygroupmap, user.UserId, tenant.TenantId); return(RedirectToAction("Index")); } ViewBag.ActivityId = new SelectList(LookupServices.GetAllActiveActivities(), "ActivityId", "ActivityName", authactivitygroupmap.ActivityId); ViewBag.ActivityGroupId = new SelectList(LookupServices.GetAllActiveActivityGroups(), "ActivityGroupId", "ActivityGroupName", authactivitygroupmap.ActivityGroupId); return(View(authactivitygroupmap)); }
public ActionResult Create([Bind(Include = "TenantEmailConfigId,TenantId,SmtpHost,SmtpPort,UserEmail,Password,EnableSsl,DateUpdated,UpdatedBy,IsActive")] TenantEmailConfig tenantemailconfig) { if (ModelState.IsValid) { // get properties of tenant caTenant tenant = caCurrent.CurrentTenant(); // get properties of user caUser user = caCurrent.CurrentUser(); _tenantEmailConfigService.SaveEmailConfig(tenantemailconfig, user.UserId, tenant.TenantId); return(RedirectToAction("Index")); } return(View(tenantemailconfig)); }
// GET: Terminals/Create public ActionResult Create() { if (!caSession.AuthoriseSession()) { return(Redirect((string)Session["ErrorUrl"])); } // get properties of tenant caTenant tenant = caCurrent.CurrentTenant(); // get current warehouse TenantLocations Warehouse = caCurrent.CurrentWarehouse(); ViewBag.WarehouseId = new SelectList(_tenantLocationServices.GetTenantLocationListById(Warehouse.WarehouseId, tenant.TenantId), "WarehouseId", "WarehouseName", Warehouse.WarehouseId); return(View()); }
public ActionResult DeleteConfirmed(int id) { if (!caSession.AuthoriseSession()) { return(Redirect((string)Session["ErrorUrl"])); } Terminals terminals = _terminalServices.GetTerminalById((int)id); // get properties of tenant caTenant tenant = caCurrent.CurrentTenant(); // get properties of user caUser user = caCurrent.CurrentUser(); _terminalServices.DeleteTerminal(terminals, user.UserId); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "TenantId,TenantName,CurrencyID,CountryID,AccountNumber,ProductCodePrefix,TenantCulture,TenantTimeZoneId,TenantNo,TenantVatNo,TenantAccountReference,TenantWebsite,TenantDayPhone,TenantEveningPhone,TenantMobilePhone,TenantFax,TenantEmail,TenantAddress1,TenantAddress2,TenantAddress3,TenantAddress4,TenantStateCounty,TenantPostalCode,TenantCity,TenantSubDmoain,IsActive")] Tenant tenants) { if (ModelState.IsValid) { // get properties of tenant caTenant tenant = caCurrent.CurrentTenant(); // get properties of user caUser user = caCurrent.CurrentUser(); tenants.DateUpdated = DateTime.UtcNow; tenants.UpdatedBy = user.UserId; _tenantServices.Update(tenants); return(RedirectToAction("Index")); } return(View(tenants)); }
public ActionResult DeleteConfirmed(int id) { if (!caSession.AuthoriseSession()) { return(Redirect((string)Session["ErrorUrl"])); } AuthActivity authactivity = _activityServices.GetActivityById((int)id); // get properties of tenant caTenant tenant = caCurrent.CurrentTenant(); // get properties of user caUser user = caCurrent.CurrentUser(); _activityServices.DeleteActivity(authactivity, user.UserId); return(RedirectToAction("Index")); }
public ActionResult Edit(AuthActivity authactivity) { if (ModelState.IsValid) { caTenant tenant = caCurrent.CurrentTenant(); caUser user = caCurrent.CurrentUser(); bool status = _activityServices.UpdateActivity(authactivity, user.UserId, tenant.TenantId); if (status == false) { ViewBag.Error = "Problem updating record. Please contact support"; return(View(authactivity)); } return(RedirectToAction("Index")); } return(View(authactivity)); }
//check if user name already exist in database public JsonResult IsUserAvailable(string UserName) { if (!String.IsNullOrEmpty(UserName)) { UserName = UserName.Trim(); } // get properties of tenant caTenant tenant = caCurrent.CurrentTenant(); int result = _userService.IsUserNameExists(UserName, tenant.TenantId); if (result > 0) { return(Json(false, JsonRequestBehavior.AllowGet)); } else { return(Json(true, JsonRequestBehavior.AllowGet)); } }
public ActionResult Index() { if (!caSession.AuthoriseSession()) { return(Redirect((string)Session["ErrorUrl"])); } // get properties of current tenant caTenant tenant = caCurrent.CurrentTenant(); //get properties of user caUser user = caCurrent.CurrentUser(); ViewData["Ten"] = user.AuthPermissions; ViewData["user"] = user; ViewData["custom"] = "Welcome <b>" + user.UserName + "</b>"; var tick = DateTime.UtcNow.Ticks; var fileTime = DateTime.UtcNow.ToFileTime(); return(View()); }
public ActionResult Edit([Bind(Include = "UserId,UserName,UserPassword,UserFirstName,UserLastName,UserEmail,IsActive")] AuthUser authuser) { if (!caSession.AuthoriseSession()) { return(Redirect((string)Session["ErrorUrl"])); } if (ModelState.IsValid) { // get properties of tenant caTenant tenant = caCurrent.CurrentTenant(); // get properties of user caUser user = caCurrent.CurrentUser(); _userService.UpdateAuthUser(authuser, user.UserId, tenant.TenantId); return(RedirectToAction("Index")); } return(View(authuser)); }
public ActionResult Create(TenantLocations tenantwarehouse) { if (!caSession.AuthoriseSession()) { return(Redirect((string)Session["ErrorUrl"])); } if (ModelState.IsValid) { // get properties of tenant caTenant tenant = caCurrent.CurrentTenant(); // get properties of user caUser user = caCurrent.CurrentUser(); _tenantLocationServices.SaveTenantLocation(tenantwarehouse, user.UserId, tenant.TenantId); return(RedirectToAction("Index")); } ViewBag.TenantLocations = LookupServices.GetAllWarehousesForTenant(CurrentTenantId).Select(m => new SelectListItem() { Value = m.WarehouseId.ToString(), Text = m.WarehouseName }); ViewBag.CountryId = new SelectList(LookupServices.GetAllGlobalCountries(), "CountryId", "CountryName"); ViewBag.AllVehicles = _marketServices.GetAllValidMarketVehicles(CurrentTenantId).MarketVehicles.Select(m => new SelectListItem() { Value = m.Id.ToString(), Text = m.Name }); ViewBag.AllTerminals = _terminalServices.GetAllTerminalsWithoutMobileLocationLinks(CurrentTenantId).Select(m => new SelectListItem() { Value = m.TerminalId.ToString(), Text = m.TerminalName + " " + m.TermainlSerial }); ViewBag.AllDrivers = _employeeServices.GetAllEmployeesWithoutResourceLinks(CurrentTenantId).Select(m => new SelectListItem() { Value = m.AuthUserId.ToString(), Text = m.SurName + " " + m.FirstName }); return(View(tenantwarehouse)); }
private void SetViewBagItems(caTenant tenant, EnumAccountType accountType = EnumAccountType.All, Order order = null) { ViewBag.Accounts = new SelectList(AccountServices.GetAllValidAccounts(CurrentTenantId, accountType), "AccountID", "AccountNameCode"); ViewBag.OrderStatus = new SelectList(LookupServices.GetAllOrderStatuses(), "OrderStatusID", "Status"); ViewBag.TransTypes = new SelectList(LookupServices.GetAllInventoryTransactionTypes() .Where(a => a.InventoryTransactionTypeId == (int)InventoryTransactionTypeEnum.SalesOrder || a.InventoryTransactionTypeId == (int)InventoryTransactionTypeEnum.Proforma || a.InventoryTransactionTypeId == (int)InventoryTransactionTypeEnum.Loan || a.InventoryTransactionTypeId == (int)InventoryTransactionTypeEnum.Exchange || a.InventoryTransactionTypeId == (int)InventoryTransactionTypeEnum.Quotation || a.InventoryTransactionTypeId == (int)InventoryTransactionTypeEnum.Samples).ToList(), "InventoryTransactionTypeId", "OrderType"); var loans = (from ln in LookupServices.GetAllValidTenantLoanTypes(CurrentTenantId) select new { LoanID = ln.LoanID, LoanName = ln.LoanName + " - Loan Days= " + ln.LoanDays }).ToList(); ViewBag.TenantLoanTypes = new SelectList(loans, "LoanID", "LoanName"); ViewBag.AuthUsers = new SelectList(OrderService.GetAllAuthorisedUsers(CurrentTenantId), "UserId", "UserName", order != null ? order.CreatedBy : CurrentUserId); ViewBag.Departments = new SelectList(LookupServices.GetAllValidTenantDepartments(CurrentTenantId), "DepartmentId", "DepartmentName"); ViewBag.AccountContacts = new SelectList(AccountServices.GetAllValidAccountContactsByAccountId(order?.AccountID ?? 0, CurrentTenantId), "AccountContactId", "ContactName", order?.AccountContactId); }
public ActionResult EditDirectSales(int?id) { if (!caSession.AuthoriseSession()) { return(Redirect((string)Session["ErrorUrl"])); } caTenant tenant = caCurrent.CurrentTenant(); string pageToken = ""; if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Order Order = OrderService.GetOrderById(id.Value); if (Order == null) { return(HttpNotFound()); } if (Order.OrderStatusID != (int)OrderStatusEnum.AwaitingAuthorisation) { TempData["ErrorAwaitingAuthorization"] = $"Order is not available to modify because order status not matched with required status."; return(RedirectToAction("AwaitingAuthorisation", "Order")); } ViewBag.AllAccounts = new SelectList(AccountServices.GetAllValidAccounts(CurrentTenantId, EnumAccountType.Customer).ToList(), "AccountID", "CompanyName", Order.AccountID); if (string.IsNullOrEmpty(pageToken)) { ViewBag.ForceRegeneratePageToken = "True"; ViewBag.ForceRegeneratedPageToken = Guid.NewGuid().ToString(); } var odList = OrderService.GetAllValidOrderDetailsByOrderId(id.Value).ToList(); GaneOrderDetailsSessionHelper.SetOrderDetailSessions(ViewBag.ForceRegeneratedPageToken, Mapper.Map(odList, new List <OrderDetailSessionViewModel>())); return(View(Order)); }
public ActionResult Tindex(int?id, int?weekNumber, int?YearsList) { if (!caSession.AuthoriseSession()) { return(Redirect((string)Session["ErrorUrl"])); } // get properties of tenant caTenant tenant = caCurrent.CurrentTenant(); caUser user = caCurrent.CurrentUser(); if (id == null) { id = CurrentWarehouseId; } if (weekNumber == null) { //get current week weekNumber = GetWeekNumber(); } if (YearsList == null) { YearsList = DateTime.UtcNow.Year; } try { List <SelectListItem> years = new List <SelectListItem>(); var currentYear = DateTime.UtcNow.Year; for (int j = 10; j >= 0; j--) { years.AddRange(new[] { new SelectListItem() { Text = (currentYear - j).ToString(), Value = (currentYear - j).ToString() } }); } ViewData["storesId"] = id; ViewBag.StoresList = new SelectList(_activityServices.GetAllPermittedWarehousesForUser(CurrentUserId, CurrentTenantId, user.SuperUser == true, false), "WId", "WName", id); ViewData["weekNumber"] = weekNumber; ViewData["yearNumber"] = YearsList; List <SelectListItem> weeks = new List <SelectListItem>(); for (int i = 1; i < 53; i++) //loop through weeks. { var placeHolder = " ( " + GetDateFromWeekNumberAndDayOfWeek(i, currentYear, 1).ToString("dd/MM") + " to " + GetDateFromWeekNumberAndDayOfWeek(i, currentYear, 0).ToString("dd/MM") + " )"; weeks.AddRange(new[] { new SelectListItem() { Text = "Week " + i + placeHolder, Value = i.ToString() } }); } ViewData["WeekDaysList"] = new SelectList(weeks, "Value", "Text", weekNumber); ViewData["YearsList"] = new SelectList(years.OrderByDescending(u => u.Value), "Value", "Text", YearsList); ViewBag.yearList = new SelectList(years.OrderByDescending(u => u.Value), "Value", "Text", YearsList); return(View()); } catch (Exception e) { //log exception var err = e.Message; return(View("_EmptyResult")); } }