コード例 #1
0
        // GET: Schedules/Create
        public ActionResult Create(int? departmentId, int? groupId)
        {
            Department department = db.Departments.Find(departmentId);
            DepartmentGroup group = db.DepartmentGroups.Find(groupId);

            if(department == null && group == null)
            {
                return HttpNotFound();
            }

            if (User.Identity.IsAuthenticated)
            {
                var userManager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(db));
                var currentUser = userManager.FindById(User.Identity.GetUserId());
                if ((department != null && department.Bosses.Contains(currentUser)) || (group != null && group.Department.Bosses.Contains(currentUser)))
                {
                    //ViewBag.DepartmentId = new SelectList(db.Departments.ToList().Where(q=>q.Bosses.Contains(currentUser)).ToList(), "Id","Name",departmentId);
                    //ViewBag.GroupId = new SelectList(db.DepartmentGroups.ToList().Where(q=>q.Department.Bosses.Contains(currentUser)).ToList(), "Id","Name",groupId);
                    ViewBag.DepartmentId = new SelectList(db.Departments.ToList().Where(q => q.Bosses.Contains(currentUser)).ToList(), "Id", "Name", departmentId);
                    var groups = new SelectList(db.DepartmentGroups.ToList().Where(q => q.Department.Bosses.Contains(currentUser)).ToList(), "Id", "Name", groupId).ToList();
                    groups.Insert(0,new SelectListItem() { Value = "", Text = "All" });
                    ViewBag.GroupId = groups;
                    return View();
                }
                else
                {
                    return new HttpStatusCodeResult(HttpStatusCode.Unauthorized);
                }

            }
            else
            {
                return new HttpStatusCodeResult(HttpStatusCode.Unauthorized);
            }
        }
コード例 #2
0
        public ActionResult Create(ProductModel model)
        {
            var _brands = unitOfWork.BrandRepository.FindAllBy(c => c.IsActive == true && c.IsDelete == false).Select(x => new { x.ID, x.Name });
            ViewBag.Brands = new SelectList(_brands, "ID", "Name");
            var _locations = unitOfWork.LocationRepository.FindAllBy(c => c.IsActive == true && c.IsDelete == false).Select(x => new { x.LocationCode, x.LocationName });
            List<SelectListItem> items = new SelectList(_locations, "LocationCode", "LocationName").ToList();
            items.Insert(0, (new SelectListItem { Text = "All", Value = "0" }));
            ViewBag.Locations = items;
            var _Categorys = unitOfWork.CategoryRepository.FindAllBy(c => c.IsActive == true && c.IsDelete == false).Select(x => new { x.ID, x.Name });
            ViewBag.Categorys = new SelectList(_Categorys, "ID", "Name");

            ViewBag.Images = unitOfWork.ProductsImagesRepository.FindAllBy(c => c.ProductCode == model.ProductCode);
            ViewBag.Videos = unitOfWork.ProductsVideosRepository.FindAllBy(c => c.ProductCode == model.ProductCode);
            try
            {
                if (ModelState.IsValid)
                {
                    var _updatedata = unitOfWork.ProductRepository.FindAllBy(c => c.ProductCode == model.ProductCode).FirstOrDefault();
                    if (_updatedata ==null)
                    {
                        unitOfWork.ProductRepository.Insert(model);
                        unitOfWork.Save();
                    }
                    else
                    {

                        _updatedata.IsActive = model.IsActive;
                        _updatedata.IsDelete = false;
                        _updatedata.ListPrice = model.ListPrice;
                        _updatedata.LocationCode = model.LocationCode;
                        _updatedata.ProductCode = model.ProductCode;
                        _updatedata.ProductName = model.ProductName;
                        _updatedata.ShortDescription = model.ShortDescription;
                        _updatedata.CategoryID = model.CategoryID;
                        _updatedata.StandardCost = model.StandardCost;
                        _updatedata.LastUpdate = DateTime.Now;
                        unitOfWork.ProductRepository.Update(_updatedata);
                        unitOfWork.Save();
                    }
                    return RedirectToAction("Index");
                }

                return View(model);

            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Property: {0} Error: {1}",
                                                validationError.PropertyName,
                                                validationError.ErrorMessage);
                    }
                }
                return View(model);
            }
        }
コード例 #3
0
ファイル: Utils.cs プロジェクト: dianaoprean/Zimbor
        public static SelectList SelectList(IEnumerable items, string valueField, string textField, string nullText, string selectedValue)
        {
            var list = new SelectList(items, valueField, textField, selectedValue).ToList();
            var selected = list.Where(x => x.Value == selectedValue).FirstOrDefault();
            if (selected != null) selected.Selected = true;

            if (nullText != null) list.Insert(0, new SelectListItem { Text = nullText, Value = 0.ToString() });
            return new SelectList(list, "Value", "Text", selectedValue);
        }
        /// <summary>
        /// Displays the list of inventory 
        /// </summary>
        /// <returns></returns>
        public ActionResult InventoryDetail()
        {
            StringBuilder objStringBuilderError = new StringBuilder();
            try
            {
                if (Session["UserName"] != null)
                {
                    InventorySearchModel inventorySearchModel = new InventorySearchModel();
                    IEnumerable<InventoryModel> lstInventoryDetails;
                    List<DeviceModel> devices;
                    using (JetstreamClient objMainServiceClient = new JetstreamClient())
                    {
                        lstInventoryDetails = objMainServiceClient.GetInventoryList(inventorySearchModel.LogicalDeviceId, inventorySearchModel.SearchString);
                        devices = objMainServiceClient.GetDeviceList();
                    }

                    List<SelectListItem> deviceList = new SelectList(devices.OrderBy(x => x.LogicalDeviceId), "LogicalDeviceId", "LogicalDeviceId").ToList();
                    deviceList.Insert(0, new SelectListItem { Text = JetstreamResource.All, Value = string.Empty });
                    ViewBag.DeviceList = deviceList;

                    SortingPagingInfo info = new SortingPagingInfo
                    {
                        SortField = Enums.InventorySortField.Material.ToString(),
                        SortDirection = Constants.Ascending,
                    };
                    lstInventoryDetails = lstInventoryDetails.OrderBy(x => x.Material).Take(Constants.PagingPageSize);
                    ViewBag.SortingPagingInfo = info;

                    if (lstInventoryDetails.Any())
                        inventorySearchModel.InventoryModels = lstInventoryDetails.ToList();

                    return View("InventoryDetail", inventorySearchModel);
                }
                else
                {
                    return RedirectToAction("UserLogin", "Login");
                }
            }
            catch (FaultException<ServiceData> fex)
            {
                objStringBuilderError.AppendLine("In method : InventoryDetail() :: InventoryController");
                objStringBuilderError.AppendFormat("ErrorMessage::{0} {1}", fex.Detail.ErrorMessage, Environment.NewLine);
                objStringBuilderError.AppendFormat("ErrorDetails::{0} {1}", Environment.NewLine, fex.Detail.ErrorDetails);

                SaveLogger.SaveLoggerError(objStringBuilderError.ToString());
                return View("Error");
            }
            catch (Exception ex)
            {
                objStringBuilderError.AppendLine("In method : InventoryDetail() :: InventoryController");
                objStringBuilderError.AppendFormat("ErrorMessage::{0} {1}", ex.Message, Environment.NewLine);
                objStringBuilderError.AppendFormat("ErrorDetails::{0} {1}", Environment.NewLine, ex.ToString());

                SaveLogger.SaveLoggerError(objStringBuilderError.ToString());
                return View("Error");
            }
        }
コード例 #5
0
        public ActionResult Create(string Pid)
        {
            var _brands=unitOfWork.BrandRepository.FindAllBy(c => c.IsActive == true && c.IsDelete == false).Select(x => new { x.ID, x.Name });
            ViewBag.Brands = new SelectList(_brands, "ID", "Name");
            var _locations = unitOfWork.LocationRepository.FindAllBy(c => c.IsActive == true && c.IsDelete == false).Select(x => new { x.LocationCode, x.LocationName });
             List<SelectListItem> items = new SelectList(_locations, "LocationCode", "LocationName").ToList();
             items.Insert(0, (new SelectListItem { Text = "ALL", Value = "ALL" }));
             ViewBag.Locations = items;

             var _Categorys = unitOfWork.CategoryRepository.FindAllBy(c => c.IsActive == true && c.IsDelete == false).Select(x => new { x.ID, x.Name });
             ViewBag.Categorys = new SelectList(_Categorys, "ID", "Name");

             ViewBag.Images = unitOfWork.ProductsImagesRepository.FindAllBy(c => c.ProductCode == Pid);
             ViewBag.Videos = unitOfWork.ProductsVideosRepository.FindAllBy(c => c.ProductCode == Pid);
             var _model = unitOfWork.ProductRepository.FindAllBy(c => c.ProductCode == Pid).FirstOrDefault();

             return View(_model);
        }
 private async Task GetSearchType(int roomallocationid)
 {
     List<SelectListItem> items = new SelectList(await _RoomAllocationRepository.GetAll(), "Id", "RoomNumber", roomallocationid).ToList();
     items.Insert(0, (new SelectListItem { Text = "Select Room #", Value = "0" }));
     ViewBag.SearchRoomAllocationId = items;
 }
        /// <summary>
        /// Method to bind the devices to device dropdown
        /// </summary>
        private void BindDevices()
        {
            StringBuilder objStringBuilderError = new StringBuilder();
            try
            {
                List<DeviceModel> devices;
                using (JetstreamClient objMainServiceClient = new JetstreamClient())
                {
                    devices = objMainServiceClient.GetDeviceList();
                }

                List<SelectListItem> deviceList = new SelectList(devices.OrderBy(x => x.LogicalDeviceId), "DeviceId", "LogicalDeviceId").ToList();
                deviceList.Insert(0, new SelectListItem { Text = JetstreamResource.Device, Value = JetstreamResource.Zero });
                ViewBag.DeviceList = deviceList;
            }
            catch (Exception ex)
            {
                objStringBuilderError.AppendLine("In method : BindDevices() :: TemperatureController");
                objStringBuilderError.AppendFormat("ErrorMessage::{0} {1}", ex.Message, Environment.NewLine);
                objStringBuilderError.AppendFormat("ErrorDetails::{0} {1}", Environment.NewLine, ex.ToString());

                SaveLogger.SaveLoggerError(objStringBuilderError.ToString());                
            }
        }
コード例 #8
0
          public async Task<List<RoomReservation_StatusViewModel>> FillStatus(RoomReservation_Status  db_status=null, long reservation_id=0 )
          {
              var list = new List<RoomReservation_StatusViewModel>();
              IEnumerable<ReservationStatusType> statuslist;
              bool isShowdb_status = false;
              if (db_status!=null)
              {

                  if (! string.IsNullOrEmpty (db_status.ReservationStatusType.Next_Status))
                  {
                      string[] next_status = db_status.ReservationStatusType.Next_Status.Split(',');
                      statuslist = await _ReservationStatusTypeRepository.GetAllEnabledbyIds(next_status);
                      statuslist = statuslist.OrderByDescending(s => s.Id);
                  }
                  else
                  {
                      isShowdb_status = true;
                      statuslist = new List<ReservationStatusType> { db_status.ReservationStatusType };
                  }

              }
              else
              {
                  statuslist = await _ReservationStatusTypeRepository.GetAllEnabled();
                 statuslist= statuslist.Where(s => s.IsDefault.Value).OrderByDescending(s => s.Id);

              }

             
             
              foreach (var status in statuslist)
              {
                  RoomReservation_Status  roomreservation_status;
                  if (isShowdb_status)
                    roomreservation_status =db_status;
                  else

                    roomreservation_status = new RoomReservation_Status();

                  RoomReservation_StatusViewModel roomreservation_statusviewmodel=new RoomReservation_StatusViewModel();
                 
                  roomreservation_statusviewmodel.RoomReservation_Status = roomreservation_status;
                  roomreservation_statusviewmodel.RoomReservation_Status.ReservationStatusTypeId = status.Id;
                  if (status.Name == RoomReservationSystem.Model.Enums.eReservationStatusType.Cancelled.ToString())
                  { // Things to do: create listtype webapi, and repository, listtype and reasons interface does not exists.
                      // var listType = await _ListTypesRepository.GetByName(RoomReservationSystem.Model.Enums.ListType.RoomReservation_CancelationReasons.ToString());

                      var cancellation_reasons = await _Reason_TypesRepository.GetbyListTypeId(((int)RoomReservationSystem.Model.Enums.ListType.RoomReservation_CancelationReasons).ToString());
                      var cancellation_reasons_selectlist = new SelectList(cancellation_reasons, "Id", "Name", roomreservation_status.Reason_TypeId).ToList();
                      cancellation_reasons_selectlist.Insert(0, new SelectListItem() { Text = "Select Reason", Value = "0" });
                      ViewBag.Reason_TypeId = cancellation_reasons_selectlist;
                  }
                  
                  roomreservation_statusviewmodel.ReservationStatusType = status;
                   
                
                  list.Add(roomreservation_statusviewmodel);
               
              }

              if (statuslist.Count()>0)

                statuslist.First().IsDefault  = true;  
              return list;


          }
コード例 #9
0
          private async Task GetTypes(RoomReservationViewModel  model=null)
          {
              ViewBag.Sponsor_ClubId = new SelectList(await _ClubRepository.GetAllEnabled(), "Id", "Name");
              ViewBag.Reservation_SourceId = new SelectList(await _Reservation_SourceRepository.GetAllEnabled(), "Id", "Name");
              ViewBag.CountryId = new SelectList(await _CountryRepository.GetAllEnabled(), "Id", "Name");
              var default_language=await _LanguageRepository.GetByName(RoomReservationSystem.Model.Enums.Language.English.ToString());
              var lang = await _LanguageRepository.GetAllEnabled();
              ViewBag.LanguageID = new SelectList(lang.OrderBy(a=>a.Name), "Id", "Name", default_language.Id);

              var titles=await _TitleRepository.GetAll();
             var titles_selectlist = new SelectList(titles.OrderBy(a=>a.Name), "Id", "Name").ToList();
              titles_selectlist.Insert(0, new SelectListItem() { Text = "Select Title", Value = "0", Selected =true});
              ViewBag.TitleID = titles_selectlist;


              var all_doctype = await _Document_TypeRepository.GetAllEnabled();

             var doc_types = new SelectList(all_doctype, "Id", "Name", 0).ToList();
                  doc_types.Insert(0, new SelectListItem() { Text = "Select Type", Value = "0", Selected =true});
                  ViewBag.Document_TypeId = doc_types;

              
              if (model == null)
              {

                  var roomtypes = new SelectList(await _RoomTypeRepository.GetAllEnabled(), "Id", "Name").ToList();
                  roomtypes.Insert(0, new SelectListItem() { Text = "Room type", Value = "0" });
                  ViewData["RoomReservation_RoomDetails.RoomTypeId"] = roomtypes;

                  var wings = new SelectList(await _WingRepository.GetAllEnabled(), "Id", "Name").ToList();
                  wings.Insert(0, new SelectListItem() { Text = "Wing", Value = "0" });
                  ViewData["Wing.WingId"] = wings;


                  List<SelectListItem> room_allocation = new List<SelectListItem>();
                  room_allocation.Insert(0, new SelectListItem() { Text = "Room #", Value = "0" });
                  ViewData["RoomReservation_RoomDetails.RoomAllocationId_0"] = room_allocation;

                 

              }
              else
              {
                  var index = 0;
                  var roomtypeslist = _RoomTypeRepository.GetAllEnabled();
                  var wingslist = _WingRepository.GetAllEnabled();



                  foreach (var roomdetailviewmodel in model.RoomReservation_RoomDetailsViewDetailList)
                  {
                      var postfix =  "_" + index;

                      var roomtypes = new SelectList(await roomtypeslist, "Id", "Name", roomdetailviewmodel.RoomReservation_RoomDetails.RoomTypeId).ToList();
                      roomtypes.Insert(0, new SelectListItem() { Text = "Room type", Value = "0" });
                      ViewData["RoomReservation_RoomDetails.RoomTypeId" + postfix] = roomtypes;

                      var wings = new SelectList(await wingslist, "Id", "Name", roomdetailviewmodel.Wing.Id).ToList();
                      wings.Insert(0, new SelectListItem() { Text = "Wing", Value = "0" });
                      ViewData["Wing.WingId" + postfix] = wings;


                      List<SelectListItem> room_allocation = new List<SelectListItem>();
                      if (roomdetailviewmodel.RoomReservation_RoomDetails.RoomTypeId.HasValue)

                          room_allocation = new SelectList(await _RoomAllocationRepository.GetByRoomTypeId(roomdetailviewmodel.RoomReservation_RoomDetails.RoomTypeId.Value), "Id", "Name", roomdetailviewmodel.RoomReservation_RoomDetails.RoomAllocationId).ToList();
                       
                      room_allocation.Insert(0, new SelectListItem() { Text = "Room #", Value = "0" });
                      ViewData["RoomReservation_RoomDetails.RoomAllocationId" + postfix ] = room_allocation;
                      index++;
                  }
              }

              var reasons = new SelectList(await _Reason_TypeRepository.GetAllEnabled(), "Id", "Name" ).ToList();

              ViewBag.Reason_TypeId = reasons;
              var pkr=await _CurrencyRepository.GetByName(RoomReservationSystem.Model.Enums.Currency.PKR.ToString());

              var currencies = new SelectList(await _CurrencyRepository.GetCurrencyForDropDoown(), "Id", "Label", pkr.Id + "|" + Math.Round (pkr.Rate.Value , 4) + "|" + pkr.Code).ToList();
              currencies.Insert(0, new SelectListItem() { Text = "Select Currency", Value = "0" });
              ViewBag.CurrencyId = currencies;


              var paymentmodes_cash = await _PaymentModeRepository.GetByName(RoomReservationSystem.Model.Enums.PaymentMode.Cash.ToString ()  );
              var paymentModes = new SelectList(await _PaymentModeRepository.GetAllEnabled(), "Id", "Name", paymentmodes_cash.Id ).ToList();
             // paymentModes.Insert(0, new SelectListItem() { Text = "Select Payment mode", Value = "0" });
              ViewBag.PaymentModeId = paymentModes;

              //For radiobutton lists in payment info
             var billtime=  await _BillTimeRepository.GetAllEnabled();
             ViewBag.BillTime_RadioButtonList = billtime.OrderByDescending(x => x.Id);
             IEnumerable<PaymentBy> paymentby;



             if (model == null)
                 paymentby = await _PaymentByRepository.PaymentBy_GetByIds((int)RoomReservationSystem.Model.Enums.BookingFor.Member, (int)RoomReservationSystem.Model.Enums.SponsorType.noType);
             else
             {
                 if (model.RoomReservation.BookingForId == (int)RoomReservationSystem.Model.Enums.BookingFor.Member)
                     model.RoomReservation.SponsorTypeId = (int)RoomReservationSystem.Model.Enums.SponsorType.noType;

                 paymentby = await _PaymentByRepository.PaymentBy_GetByIds(model.RoomReservation.BookingForId, (model.RoomReservation.SponsorTypeId.HasValue ? model.RoomReservation.SponsorTypeId.Value : 0)); }

      
              ViewBag.PaymentBy_RadioButtonList =   paymentby.OrderByDescending(x => x.Id);

              if ((model != null) && ( model.RoomReservation.Member ==null))
              {

                  model.RoomReservation.Member = new Member();
              }

          }
コード例 #10
0
ファイル: Utils.cs プロジェクト: dianaoprean/Zimbor
 public static SelectList SelectList(IEnumerable items, string valueField, string textField, string nullText, bool isDefaultNull)
 {
     var list = new SelectList(items, valueField, textField).ToList();
     if (nullText != null) list.Insert(0, new SelectListItem { Text = nullText, Value = isDefaultNull ? string.Empty : 0.ToString() });
     return new SelectList(list, "Value", "Text");
 }
 private async Task GetSearchType(int SearchRoomTypeId, int SearchWaitingListStatusId)
 {
     List<SelectListItem> items = new SelectList(await _RoomTypeRepository.GetAllEnabled(), "Id", "Name", SearchRoomTypeId).ToList();
     items.Insert(0, (new SelectListItem { Text = "Any", Value = "0" }));
     items.Insert(0, (new SelectListItem { Text = "Select room type", Value = "-1" }));
     ViewBag.SearchRoomTypeId = items;
     List<SelectListItem> status = new SelectList(await _WaitingListStatusRepository.GetAllEnabled(), "Id", "Name", SearchWaitingListStatusId).ToList(); 
     status.Insert(0, (new SelectListItem { Text = "Select Status", Value = "0" }));
     ViewBag.SearchWaitingListStatusId = status;
 }
コード例 #12
0
        private void LlenarControles(UsuarioModel model)
        {
            var proveedores = Uow.Proveedores.Listado().Where(p => p.CuentaId == UsuarioActual.CuentaId).ToList();
            model.Proveedores = proveedores.Select(r => new SelectListItem()
            {
                Text = r.Nombre,
                Value = r.ProveedorId.ToString()
            }).ToList();

            var listado = Uow.Usuarios.RolesListado().ToList();
            listado.RemoveAt(3);
            var roles = new SelectList(listado, "RoleId", "RoleName").ToList();
            roles.Insert(0, new SelectListItem());
            ViewBag.Roles = new SelectList(roles, "Value", "Text");
        }
コード例 #13
0
        public ActionResult Create([Bind(Include = "Id,StartTime,EndTime,DepartmentId,GroupId")] Schedule schedule)
        {
            var userManager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(db));
            var currentUser = userManager.FindById(User.Identity.GetUserId());

            if (ModelState.IsValid && User.Identity.IsAuthenticated)
            {
                if (schedule.DepartmentId == 0 && schedule.GroupId == null)
                {
                    return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
                }
                Department department = db.Departments.Find(schedule.DepartmentId) ?? db.DepartmentGroups.Find(schedule.GroupId).Department;
                if (department == null)
                {
                    return HttpNotFound();
                }
                if (department.Bosses.Contains(currentUser)) //Current logged in user must be boss for the department
                {
                    db.Schedules.Add(schedule);
                    db.SaveChanges();

                    return RedirectToAction("Index", "Schedules", new { departmentId = schedule.DepartmentId, groupId = schedule.GroupId });
                }
                else
                {
                    return new HttpStatusCodeResult(HttpStatusCode.Unauthorized);
                }
            }
            ViewBag.DepartmentId = new SelectList(db.Departments.ToList().Where(q => q.Bosses.Contains(currentUser)).ToList(), "Id", "Name", schedule.DepartmentId);
            var groups = new SelectList(db.DepartmentGroups.ToList().Where(q => q.Department.Bosses.Contains(currentUser)).ToList(), "Id", "Name", schedule.GroupId).ToList();
            groups.Insert(0,new SelectListItem(){ Value = "", Text = "All"});
            ViewBag.GroupId = groups;

            return View(schedule);
        }
コード例 #14
0
        public ActionResult Edit([Bind(Include = "Id,StartTime,EndTime,DepartmentId,GroupId")] Schedule schedule)
        {
            var userManager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(db));
            var currentUser = userManager.FindById(User.Identity.GetUserId());
            if (ModelState.IsValid && User.Identity.IsAuthenticated)
            {
                if (schedule.Id == 0)
                {
                    return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
                }
                Schedule dbSchedule = db.Schedules.Find(schedule.Id);
                if (dbSchedule == null)
                {
                    return HttpNotFound();
                }
                if (dbSchedule.Department.Bosses.Contains(currentUser) || (dbSchedule.Group != null && dbSchedule.Group.Department.Bosses.Contains(currentUser)))
                {
                    db.Entry(dbSchedule).State = EntityState.Detached;

                    db.Entry(schedule).State = EntityState.Modified;
                    db.SaveChanges();

                    return RedirectToAction("Index", "Schedules", new { id = schedule.DepartmentId });
                }
                else
                {
                    return new HttpStatusCodeResult(HttpStatusCode.Unauthorized);
                }
            }

            ViewBag.DepartmentId = new SelectList(db.Departments.ToList().Where(q => q.Bosses.Contains(currentUser)).ToList(), "Id", "Name", schedule.DepartmentId);
            var groups = new SelectList(db.DepartmentGroups.ToList().Where(q => q.Department.Bosses.Contains(currentUser)).ToList(), "Id", "Name", schedule.GroupId).ToList();
            groups.Insert(0, new SelectListItem() { Value = "", Text = "All" });
            ViewBag.GroupId = groups;

            return View(schedule);
        }
コード例 #15
0
        // GET: Schedules/Edit/5
        public ActionResult Edit(int? id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            Schedule schedule = db.Schedules.Find(id);
            if (schedule == null)
            {
                return HttpNotFound();
            }

            if (User.Identity.IsAuthenticated)
            {
                var userManager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(db));
                var currentUser = userManager.FindById(User.Identity.GetUserId());
                if (schedule.Department.Bosses.Contains(currentUser) || (schedule.Group != null && schedule.Group.Department.Bosses.Contains(currentUser)))
                {
                    ViewBag.DepartmentId = new SelectList(db.Departments.ToList().Where(q => q.Bosses.Contains(currentUser)).ToList(), "Id", "Name", schedule.DepartmentId);
                    var groups = new SelectList(db.DepartmentGroups.ToList().Where(q => q.Department.Bosses.Contains(currentUser)).ToList(), "Id", "Name", schedule.GroupId).ToList();
                    groups.Insert(0, new SelectListItem() { Value = "", Text = "All" });
                    ViewBag.GroupId = groups;

                    return View(schedule);
                }
                else
                {
                    return new HttpStatusCodeResult(HttpStatusCode.Unauthorized);
                }

            }
            else
            {
                return new HttpStatusCodeResult(HttpStatusCode.Unauthorized);
            }
        }
コード例 #16
0
ファイル: Utils.cs プロジェクト: dianaoprean/Zimbor
 public static SelectList SelectListTextValue(IEnumerable items, string valueField, string textField, string nullText, string nullTextValue)
 {
     var list = new SelectList(items, valueField, textField).ToList();
     if (nullText != null) list.Insert(0, new SelectListItem { Text = nullText, Value = nullTextValue });
     return new SelectList(list, "Value", "Text");
 }
        private async Task GetType(int? RoomTypeId,int WaitingListStatusId)
        {

            var roomtypes=await _RoomTypeRepository.GetAllEnabled();

          
            List<SelectListItem> items = new SelectList(roomtypes, "Id", "Name",(RoomTypeId!=null) ? RoomTypeId.Value: 0).ToList();
        items.Insert(0, (new SelectListItem { Text = "Any", Value = "0" }));
        ViewBag.RoomTypeId = items;
        var list = await _WaitingListStatusRepository.GetAllEnabled();
        ViewBag.WaitingListStatusId = new SelectList(list.OrderBy(a=> a.Id), "Id", "Name",  WaitingListStatusId);
        }
コード例 #18
0
        private void LlenarControles()
        {
            var provedores = new SelectList(Uow.Proveedores.Listado(), "ProveedorId", "Nombre").ToList();
            provedores.Insert(0, new SelectListItem());
            ViewBag.Proveedores = new SelectList(provedores, "Value", "Text");

            var kioscos = new SelectList(Uow.MaxiKioscos.Listado(), "MaxiKioscoId", "Nombre").ToList();
            kioscos.Insert(0, new SelectListItem());
            ViewBag.MaxiKioscos = new SelectList(kioscos, "Value", "Text");
        }
コード例 #19
0
        public ActionResult Edit(int id = 0)
        {
            ImageDetail imgdtls = db.ImageDetails.Find(id);
            if (imgdtls == null)
            {
            return HttpNotFound();
            }
            ViewBag.Categories = new SelectList(db.Categories, "CategoryId", "CategoryName", imgdtls.CategoryId);

            List<SelectListItem> items = new SelectList(db.Artists, "ArtistsId", "ArtistsName", imgdtls.ArtistId).ToList();
            items.Insert(0, (new SelectListItem { Text = "- Select Artist -", Value = "0" }));
            ViewBag.Artist = items;
               // ViewBag.Artist = new SelectList(db.Artists, "ArtistsId", "ArtistsName", imgdtls.ArtistId);
            return View(imgdtls);
        }
コード例 #20
0
        private void CreateDropDownLists()
        {
            List<SelectListItem> lists;

            lists = new SelectList(viverbembd.Client, "ClientID", "Name").ToList();
            lists.Insert(0, (new SelectListItem { Text = "-- escolha um cliente --", Value = "" }));
            ViewBag.ClientID = lists;


            lists = new SelectList(viverbembd.NewsPaperSizes, "NewsPaperSizesID", "SizeName").ToList();
            lists.Insert(0, (new SelectListItem { Text = "-- escolha uma medida --", Value = "" }));
            ViewBag.NewsPaperSizesID = lists;


            lists = new SelectList(viverbembd.PaymentForm, "PaymentFormID", "PaymentFormName").ToList();
            lists.Insert(0, (new SelectListItem { Text = "-- escolha uma forma de pagamento --", Value = "" }));
            ViewBag.PaymentFormID = lists;


            lists = new SelectList(viverbembd.Sellers, "SellersID", "SellerName").ToList();
            lists.Insert(0, (new SelectListItem { Text = "-- escolha um vendedor --", Value = "" }));
            ViewBag.SellersID = lists;

            lists = new SelectList(viverbembd.SalesSituation, "SalesSituationID", "SituationName").ToList();
            lists.Insert(0, (new SelectListItem { Text = "-- escolha uma situação --", Value = "" }));
            ViewBag.SalesSituationID = lists;

        }
コード例 #21
0
        private  async Task GetSearchTypes(int? roomTypeid, int? wingid, int? statusid)
        {
            List<SelectListItem> roomTypes = new SelectList(await _RoomTypeRepository.GetAllEnabled(), "Id", "Name", roomTypeid).ToList();
            roomTypes.Insert(0, (new SelectListItem { Text = "Select Type", Value = "0" }));
            ViewBag.SearchRoomTypeId = roomTypes;

            List<SelectListItem> wings = new SelectList(await _WingRepository.GetAllEnabled(), "Id", "Name", wingid).ToList();
            wings.Insert(0, (new SelectListItem { Text = "Select Wing", Value = "0" }));
            ViewBag.SearchWingId = wings;
            List<SelectListItem> status = new SelectList(await _RoomStatusTypeRepository.GetAllEnabled(), "Id", "Name", statusid).ToList();
            status.Insert(0, (new SelectListItem { Text = "Select Status", Value = "0" }));

            ViewBag.SearchRoomStatusTypeId = status;


        }
コード例 #22
0
 private async Task GetRateType(Facility facility)
 {
     List<SelectListItem> items = new SelectList(await _RateTypeRepository.GetAllEnabled(), "Id", "Name", facility.RateTypeId).ToList();
 items.Insert(0, (new SelectListItem { Text = "Select Rate Type", Value = "0" }));
 ViewBag.RateTypeId = items;
 }