public ActionResponse Add(SectorModel model) { using (var unitWork = new UnitOfWork(context)) { ActionResponse response = new ActionResponse(); IMessageHelper mHelper; try { var sectorType = unitWork.SectorTypesRepository.GetByID(model.SectorTypeId); if (sectorType == null) { mHelper = new MessageHelper(); response.Message = mHelper.GetNotFound("Sector Type"); response.Success = false; return(response); } var isSectorCreated = unitWork.SectorRepository.GetOne(s => s.SectorName.ToLower() == model.SectorName.ToLower() && s.SectorTypeId == sectorType.Id); if (isSectorCreated != null) { response.ReturnedId = isSectorCreated.Id; } else { var parentSector = unitWork.SectorRepository.GetByID(model.ParentId); EFSector newSector = null; if (parentSector != null) { newSector = unitWork.SectorRepository.Insert(new EFSector() { SectorType = sectorType, ParentSector = parentSector, SectorName = model.SectorName, IATICode = model.IATICode, TimeStamp = DateTime.Now, }); } else { newSector = unitWork.SectorRepository.Insert(new EFSector() { SectorType = sectorType, SectorName = model.SectorName, IATICode = model.IATICode, TimeStamp = DateTime.Now }); } unitWork.Save(); response.ReturnedId = newSector.Id; } } catch (Exception ex) { response.Success = false; response.Message = ex.Message; } return(response); } }
public async Task <IActionResult> Edit(int id, [Bind("Id,Nombre")] SectorModel sectorModel) { if (id != sectorModel.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(sectorModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SectorModelExists(sectorModel.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(sectorModel)); }
public bool EditarSector(SectorModel sectorModel) { SqlCommand cmd = null; bool prueba; cmd = new SqlCommand("update Sectores set nombreSector=@nombreSector,provincia=@provincia" + " where codigo= @codigo", conectar.conn); cmd.CommandType = CommandType.Text; cmd.Parameters.Add(new SqlParameter("@codigo", sectorModel.Codigo)); cmd.Parameters.Add(new SqlParameter("@nombreSector", sectorModel.NombreSector)); cmd.Parameters.Add(new SqlParameter("@provincia", sectorModel.Provincia)); conectar.abrir(); int resultado = cmd.ExecuteNonQuery(); cmd = null; conectar.cerrar(); if (resultado > 0) { prueba = true; } else { prueba = false; } return(prueba); }
public IActionResult Index() { if (!Middleware.CheckUserPermission(PermissionType.Admin, HttpContext)) { return(RedirectToAction("Login", "User")); } List <Sector> sectors = SectorContainer.GetAll(); // FIXME: Kan dit beter ? SectorListViewModel slvm = new SectorListViewModel(); slvm.Sectors = new List <SectorModel>(); foreach (Sector sector in sectors) { SectorModel temp = new SectorModel(); temp.Id = sector.Id; temp.Name = sector.Name; slvm.Sectors.Add(temp); } return(View(slvm)); }
public bool guardarSector(SectorModel sectorModel) { SqlCommand cmd = null; bool prueba; cmd = new SqlCommand(" insert into Sectores(nombreSector,provincia)" + " values (@nombreSector,@provincia)", conectar.conn); cmd.CommandType = CommandType.Text; cmd.Parameters.Add(new SqlParameter("@nombreSector", sectorModel.NombreSector)); cmd.Parameters.Add(new SqlParameter("@provincia", sectorModel.Provincia)); conectar.abrir(); int resultado = cmd.ExecuteNonQuery(); cmd = null; conectar.cerrar(); if (resultado > 0) { prueba = true; } else { prueba = false; } return(prueba); }
private void btnGuardar_Click(object sender, EventArgs e) { if (txtSector.Text == "" || cbbProvincias.Text == "") { MessageBox.Show("faltan datos"); return; } else { SectorModel sectorModel = new SectorModel { NombreSector = txtSector.Text, Provincia = cbbProvincias.Text }; if (dSector.guardarSector(sectorModel) == true) { cargarProvinciasAll(); limpiar(); desabilitar_textbox(); btnGuardar.Visible = false; btnnuevo.Visible = true; btnEditar.Enabled = false; btnEliminar.Enabled = false; btbcancelar.Enabled = false; } else { MessageBox.Show("Error al guardar datos"); } } }
//--------------------------------------------------------------------------------------------------- //Sector Tab //--------------------------------------------------------------------------------------------------- //Display Data Table public ActionResult GetSectorDTable() { SectorModel model = new SectorModel(); List <SectorList> getSectorList = new List <SectorList>(); var SQLQuery = "SELECT * FROM [Tbl_FMSector_Sector]"; using (SqlConnection Connection = new SqlConnection(GlobalFunction.ReturnConnectionString())) { Connection.Open(); using (SqlCommand command = new SqlCommand("[dbo].[SP_Sector]", Connection)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.Add(new SqlParameter("@SQLStatement", SQLQuery)); SqlDataReader dr = command.ExecuteReader(); while (dr.Read()) { getSectorList.Add(new SectorList() { SectorID = GlobalFunction.ReturnEmptyInt(dr[0]), SectorTitle = GlobalFunction.ReturnEmptyString(dr[1]), SectorCode = GlobalFunction.ReturnEmptyString(dr[2]) }); } } Connection.Close(); } model.getSectorList = getSectorList.ToList(); return(PartialView("SectorTab/_TableSector", model.getSectorList)); }
private void CompanyGridViewLoaded(object sender, RoutedEventArgs e) { var companyGridView = sender as GridView; if (companyGridView == null) { return; } _currentSector = ((FrameworkElement)sender).DataContext as SectorModel; if (_currentSector == null) { return; } _currentSector.Companies = AdjustCompaniesForUI(_currentSector.Companies); companyGridView.ItemsSource = _currentSector.Companies; if (_model.Settings.DisplayType == DisplayType.Ratings) { companyGridView.ItemTemplate = App.Current.Resources["RatingCompanyTileGridViewItemTemplate"] as DataTemplate; } else { companyGridView.ItemTemplate = App.Current.Resources["EstimatesCompanyTileGridViewItemTemplate"] as DataTemplate; } }
private void FillViewSelectionChanged(object sender, SelectionChangedEventArgs e) { var sector = FillView.SelectedItem as SectorModel; if (sector != null) { _currentSector = sector; } }
public SectorModel ConvertSectorToSectorModel(Logic.Sector sector) { SectorModel sectorModel = new SectorModel(); sectorModel.Id = sector.Id; sectorModel.Name = sector.Name; return(sectorModel); }
public Logic.Sector ConvertSectorModelToSector(SectorModel sectorModel) { Logic.Sector sector = new Logic.Sector(); sector.Id = sectorModel.Id; sector.Name = sectorModel.Name; return(sector); }
public IActionResult Add([FromBody] SectorModel SectorModel) { Sector sector = new Sector(); sector.Name = SectorModel.Name; _SectorRepo.Insert(sector); _SectorRepo.Save(); return(Ok(true)); }
public async Task <IActionResult> Create([Bind("Id,Nombre")] SectorModel sectorModel) { if (ModelState.IsValid) { _context.Add(sectorModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(sectorModel)); }
public IActionResult Create(SectorModel sectorModel) { if (!Middleware.CheckUserPermission(PermissionType.Admin, HttpContext)) { return(RedirectToAction("Login", "User")); } SectorContainer.Save(sectorModel); return(RedirectToAction("Index")); }
public IActionResult Create(SectorModel sectorModel) { if (!this._middleware.CheckUserPermission(PermissionType.Admin, HttpContext)) { return(RedirectToAction("Login", "User")); } SectorConverter sectorConverter = new SectorConverter(); this._sectorContainer.Save(sectorConverter.ConvertSectorModelToSector(sectorModel)); return(RedirectToAction("Index")); }
public IActionResult Edit(SectorModel sectorModel) { if (!Middleware.CheckUserPermission(PermissionType.Admin, HttpContext)) { return(RedirectToAction("Login", "User")); } if (SectorContainer.Update(sectorModel)) { return(RedirectToAction("Index")); } return(RedirectToAction("Edit", sectorModel.Id)); }
public ActionResult GetSectorForm(int ActionID, int PrimaryID) { SectorModel model = new SectorModel(); if (ActionID == 2) { var sector = (from a in BOSSDB.Tbl_FMSector_Sector where a.SectorID == PrimaryID select a).FirstOrDefault(); model.SectorList.SectorTitle = sector.SectorTitle; model.SectorList.SectorCode = sector.SectorCode; model.SectorList.SectorID = sector.SectorID; } model.ActionID = ActionID; return(PartialView("SectorTab/_SectorForm", model)); }
public ActionResponse Update(int id, SectorModel model) { using (var unitWork = new UnitOfWork(context)) { ActionResponse response = new ActionResponse(); IMessageHelper mHelper; var sectorCategory = unitWork.SectorCategoryRepository.GetByID(model.CategoryId); if (sectorCategory == null) { mHelper = new MessageHelper(); response.Message = mHelper.GetNotFound("Sector Category"); response.Success = false; return(response); } var sectorSubCategory = unitWork.SectorSubCategoryRepository.GetByID(model.SubCategoryId); if (sectorSubCategory == null) { mHelper = new MessageHelper(); response.Message = mHelper.GetNotFound("Sector Sub-Category"); response.Success = false; return(response); } var sectorObj = unitWork.SectorRepository.GetByID(id); if (sectorObj == null) { mHelper = new MessageHelper(); response.Success = false; response.Message = mHelper.GetNotFound("Sector"); return(response); } try { sectorObj.Category = sectorCategory; sectorObj.SubCategory = sectorSubCategory; sectorObj.SectorName = model.SectorName; unitWork.SectorRepository.Update(sectorObj); unitWork.Save(); } catch (Exception ex) { response.Success = false; response.Message = ex.Message; } return(response); } }
public IActionResult Post([FromBody] SectorModel sector) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var response = sectorService.Add(sector); if (!response.Success) { return(BadRequest(response.Message)); } return(Ok(response.ReturnedId)); }
public IActionResult Put(int id, [FromBody] SectorModel sector) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var response = sectorService.Update(id, sector); if (!response.Success) { return(BadRequest(response.Message)); } return(Ok(response.Message)); }
public IActionResult Edit(int id) { if (!Middleware.CheckUserPermission(PermissionType.Admin, HttpContext)) { return(RedirectToAction("Login", "User")); } Sector sector = SectorContainer.GetSectorById(id); SectorModel sectorModel = new SectorModel(); sectorModel.Id = sector.Id; sectorModel.Name = sector.Name; return(View(sectorModel)); }
public IActionResult Edit([FromBody] SectorModel SectorModel) { var sector = _SectorRepo.GetById(SectorModel.id); if (sector == null) { return(Ok(false)); } // Employee employee = new Employee(); sector.Name = SectorModel.Name; _SectorRepo.Update(sector); _SectorRepo.Save(); return(Ok(true)); }
public ActionResponse Add(SectorModel model) { using (var unitWork = new UnitOfWork(context)) { ActionResponse response = new ActionResponse(); IMessageHelper mHelper; try { var sectorCategory = unitWork.SectorCategoryRepository.GetByID(model.CategoryId); if (sectorCategory == null) { mHelper = new MessageHelper(); response.Message = mHelper.GetNotFound("Sector Category"); response.Success = false; return(response); } var sectorSubCategory = unitWork.SectorSubCategoryRepository.GetByID(model.SubCategoryId); if (sectorSubCategory == null) { mHelper = new MessageHelper(); response.Message = mHelper.GetNotFound("Sector Sub-Category"); response.Success = false; return(response); } var newSector = unitWork.SectorRepository.Insert(new EFSector() { Category = sectorCategory, SubCategory = sectorSubCategory, SectorName = model.SectorName, TimeStamp = DateTime.Now }); response.ReturnedId = newSector.Id; unitWork.Save(); } catch (Exception ex) { response.Success = false; response.Message = ex.Message; } return(response); } }
private void SnappedViewLoaded(object sender, RoutedEventArgs e) { ListView lstView = (ListView)sender; SectorModel currentSector = ((FrameworkElement)sender).DataContext as SectorModel; if (_model.DisplayMode.DisplayType == DisplayType.Ratings) { lstView.Style = (Style)App.Current.Resources["CompanyRatingSnappedListView"]; } else { lstView.Style = (Style)App.Current.Resources["CompanyEstimateSnappedListView"]; } lstView.ItemsSource = currentSector.Companies; lstView.IsItemClickEnabled = true; lstView.ItemClick += SnappedItemClick; }
public ActionResponse Update(int id, SectorModel model) { using (var unitWork = new UnitOfWork(context)) { ActionResponse response = new ActionResponse(); IMessageHelper mHelper; var sectorType = unitWork.SectorTypesRepository.GetByID(model.SectorTypeId); if (sectorType == null) { mHelper = new MessageHelper(); response.Success = false; response.Message = mHelper.GetNotFound("Sector Type"); return(response); } var parentSector = unitWork.SectorRepository.GetByID(model.ParentId); var sectorObj = unitWork.SectorRepository.GetByID(id); if (sectorObj == null) { mHelper = new MessageHelper(); response.Success = false; response.Message = mHelper.GetNotFound("Sector"); return(response); } try { sectorObj.SectorType = sectorType; sectorObj.ParentSector = parentSector; sectorObj.SectorName = model.SectorName.Trim(); unitWork.SectorRepository.Update(sectorObj); unitWork.Save(); } catch (Exception ex) { response.Success = false; response.Message = ex.Message; } return(response); } }
public Sector(SectorModel sectorModel) { throw new NotImplementedException(); }
public SectorDTO(SectorModel sectorModel) { this.Id = sectorModel.Id; this.Name = sectorModel.Name; }
// GET: FileMaintenanceSector public ActionResult FileSector() { SectorModel model = new SectorModel(); return(View()); }
public ActionResult GetSectorTab() { SectorModel model = new SectorModel(); return(PartialView("SectorTab/IndexSectorTab", model)); }
public ActionResult SaveSector(SectorModel model) { var isExist = ""; if (ModelState.IsValid) { var SectorTitle = model.SectorList.SectorTitle; SectorTitle = new CultureInfo("en-US").TextInfo.ToTitleCase(SectorTitle); Tbl_FMSector_Sector checkSector = (from a in BOSSDB.Tbl_FMSector_Sector where (a.SectorTitle == SectorTitle || a.SectorCode == model.SectorList.SectorCode) select a).FirstOrDefault(); if (model.ActionID == 1) { if (checkSector == null) { Tbl_FMSector_Sector Sector = new Tbl_FMSector_Sector(); Sector.SectorTitle = SectorTitle; Sector.SectorCode = model.SectorList.SectorCode; BOSSDB.Tbl_FMSector_Sector.Add(Sector); BOSSDB.SaveChanges(); isExist = "false"; } else if (checkSector != null) { isExist = "true"; } } else if (model.ActionID == 2) { Tbl_FMSector_Sector Sector = (from a in BOSSDB.Tbl_FMSector_Sector where a.SectorID == model.SectorList.SectorID select a).FirstOrDefault(); List <Tbl_FMSector_Sector> sectorTitlelist = (from e in BOSSDB.Tbl_FMSector_Sector where e.SectorTitle == SectorTitle select e).ToList(); List <Tbl_FMSector_Sector> sectorCode = (from e in BOSSDB.Tbl_FMSector_Sector where e.SectorCode == model.SectorList.SectorCode select e).ToList(); if (checkSector != null) { if (Sector.SectorTitle == SectorTitle && Sector.SectorCode == model.SectorList.SectorCode) //walang binago { Sector.SectorTitle = SectorTitle; Sector.SectorCode = model.SectorList.SectorCode; BOSSDB.Entry(Sector); BOSSDB.SaveChanges(); isExist = "justUpdate"; } else { if (Sector.SectorTitle != SectorTitle && sectorTitlelist.Count >= 1 || Sector.SectorCode != model.SectorList.SectorCode && sectorCode.Count >= 1) { isExist = "true"; } else { Sector.SectorTitle = SectorTitle; Sector.SectorCode = model.SectorList.SectorCode; BOSSDB.Entry(Sector); BOSSDB.SaveChanges(); isExist = "justUpdate"; } } } else if (checkSector == null) { Sector.SectorTitle = SectorTitle; Sector.SectorCode = model.SectorList.SectorCode; BOSSDB.Entry(Sector); BOSSDB.SaveChanges(); isExist = "justUpdate"; } } } return(new JsonResult() { JsonRequestBehavior = JsonRequestBehavior.AllowGet, Data = new { isExist = isExist } }); }
public ShipDestinationInfo(SectorModel sector, Vector3 fstOffset) { Target = sector; _fstOffset = fstOffset; _closeEnoughDistance = sector.Radius; _progressCheckDistance = sector.Radius / 4F; }