public void Modificar(ConceptViewModel pConceptViewModel) { using (var scope = new TransactionScope()) { concepts oconcepts = oRepositorio.FindById(pConceptViewModel.concept_id); oconcepts.concept = pConceptViewModel.concept; oconcepts.summary = pConceptViewModel.summary; oconcepts.pdf_path = pConceptViewModel.pdf_path; oconcepts.user_id_modified = pConceptViewModel.user_id_modified; oconcepts.concept_status_id = pConceptViewModel.concept_status_id; // oconcepts.tags = oRepositorioTag.TagsByfilters(pConceptViewModel.tag_ids); oconcepts.date_modified = DateTime.Now; oRepositorio.Update(oconcepts); //oconcepts.tags = oRepositorioTag.TagsByfilters(pConceptViewModel.tag_ids); // oconcepts = oRepositorio.Add(oconcepts); oRepositorioConceptTag.DeleleMultiple(oconcepts.concept_id); foreach (int tag_id in pConceptViewModel.tag_ids) { concepts_tags oconcepts_tags = new concepts_tags { concept_id = oconcepts.concept_id, tag_id = tag_id, date_created = DateTime.Now, user_id_created = pConceptViewModel.user_id_created }; oRepositorioConceptTag.Add(oconcepts_tags); } oUnitOfWork.SaveChanges(); scope.Complete(); } }
// GET: Concept public async Task <ActionResult> Index(int?id) { var model = new ConceptViewModel(); var user = await GetCurrentUserAsync(); model.SoftwareLanguage = await _context .SoftwareLanguages.FirstOrDefaultAsync(sl => sl.Id == id); model.ConceptsWithStuff = await _context .Concepts .Where(c => c.SoftwareLanguageId == id) .Select(c => new ConceptWithDescriptionAndLink() { ConceptId = c.Id, ConceptName = c.Name, SoftwareLanguageId = id, ApplicationUserId = c.ApplicationUserId, UsefulLinks = c.UsefulLinks.ToList(), Descriptions = c.Descriptions.ToList() }).ToListAsync(); model.LoggedInUser = user; return(View(model)); }
public IHttpActionResult Calificar(ConceptQualificationViewModel filter) { // falta validar q ya lo haya calificado ConceptBL oConceptBL = new ConceptBL(); var calificado = oConceptBL.VerificarCalificado(filter.concept_id); ConceptStatusLogViewModel oConceptStatusLogViewModel = new ConceptStatusLogViewModel(); oConceptStatusLogViewModel.concept_id = filter.concept_id; oConceptStatusLogViewModel.user_id_created = filter.user_id; oConceptStatusLogViewModel.qualification = filter.qualification; //oConceptStatusLogViewModel.certification_path = pdf_path; oConceptBL.Calificar(oConceptStatusLogViewModel); if (!calificado) { ConceptViewModel pConceptViewModel = oConceptBL.Obtener(oConceptStatusLogViewModel.concept_id); NotificacionCalificadoConcepto(pConceptViewModel); } var result = new { data = 1 }; return(Ok(result)); }
private void NotificacionCalificadoConcepto(ConceptViewModel pConceptViewModel) { var base_url = ConfigurationManager.AppSettings["site.url"]; UserBL userBL = new UserBL(); UserViewModel investigador = userBL.ObtenerUser(pConceptViewModel.user_id_created.Value); SendEmailNotificationBL oSendEmailNotificationBL = new SendEmailNotificationBL(); NotificationConceptViewModel oNotificationConceptViewModel = new NotificationConceptViewModel(); oNotificationConceptViewModel.name = investigador.contact_name; oNotificationConceptViewModel.url_view_concept = base_url + @"/Concept"; oNotificationConceptViewModel.to = investigador.user_email; oNotificationConceptViewModel.url_politicas = ConfigurationManager.AppSettings["site.url.politicas"]; oNotificationConceptViewModel.url_contacto = ConfigurationManager.AppSettings["site.url.contacto"]; oNotificationConceptViewModel.url_privacidad = ConfigurationManager.AppSettings["site.url.privacidad"]; oNotificationConceptViewModel.draft_law_title = pConceptViewModel.title; oSendEmailNotificationBL.EnviarNotificacionConcepto(oNotificationConceptViewModel, "notificacion.concept.calificado"); NotificationBL oNotificationBL = new NotificationBL(); NotificationViewModel pNotificationViewModel = new NotificationViewModel(); pNotificationViewModel.user_id = investigador.id; pNotificationViewModel.message = "El concepto con nĂºmero '" + pConceptViewModel.concept_id + "' ha sido calificado."; pNotificationViewModel.url = @"/Concept"; oNotificationBL.Agregar(pNotificationViewModel); }
/// <summary> /// Mapea un modelo de vista /// a una entidad /// </summary> public concept ViewModelToEntity(ConceptViewModel model) { concept result = new concept(); result.ConceptId = model.ConceptId; result.Nombre = model.Nombre; result.RegStatus = model.RegStatus; result.CreatedAt = Convert.ToDateTime(model.CreatedAt); result.UpdatedAt = Convert.ToDateTime(model.UpdatedAt); return(result); }
/// <summary> /// mapea un objeto entidad /// a un modelo de vista /// </summary> public ConceptViewModel EntityToViewModel(concept entity) { var model = new ConceptViewModel(); model.ConceptId = entity.ConceptId; model.Nombre = entity.Nombre; model.RegStatus = entity.RegStatus; model.CreatedAt = entity.CreatedAt.ToString("dd/MM/yyyy"); model.UpdatedAt = entity.UpdatedAt.ToString("dd/MM/yyyy"); return(model); }
public ActionResult ViewConcept(Guid id, Guid?versionId) { try { var bundle = this.ImsiClient.Query <Concept>(c => c.Key == id && c.ObsoletionTime == null, 0, null, true); bundle.Reconstitute(); var concept = bundle.Item.OfType <Concept>().FirstOrDefault(c => c.Key == id && c.ObsoletionTime == null); if (concept == null) { TempData["error"] = Locale.ConceptNotFound; return(RedirectToAction("Index")); } // force load concept class if the server didn't return it if (concept.Class == null && concept.ClassKey.HasValue && concept.ClassKey.Value != Guid.Empty) { concept.Class = this.GetConceptClass(concept.ClassKey.Value); } // load the concept sets concept.ConceptSetsXml = this.LoadConceptSets(concept.Key.Value); foreach (var conceptSetKey in concept.ConceptSetsXml) { var conceptSet = this.ImsiClient.Get <ConceptSet>(conceptSetKey, null) as ConceptSet; if (conceptSet != null) { concept.ConceptSets.Add(conceptSet); } } var model = new ConceptViewModel(concept) { ReferenceTerms = this.GetConceptReferenceTerms(id, versionId).Select(r => new ReferenceTermViewModel(r)).ToList() }; return(View(model)); } catch (Exception e) { Trace.TraceError($"Unable to load concept: {e}"); this.TempData["error"] = Locale.UnexpectedErrorMessage; } return(RedirectToAction("Index")); }
public ActionResult Update(ConceptViewModel model) { ResponseViewModel resp = new ResponseViewModel(); try { resp = ConceptObject.Update(model); } catch (Exception ex) { resp.Success = false; resp.Message = ex.Message; } return Json(resp, JsonRequestBehavior.AllowGet); }
public void Agregar(ConceptViewModel pConceptViewModel) { using (var scope = new TransactionScope()) { concepts oconcepts = new concepts { concept_id = 0, concept = pConceptViewModel.concept, summary = pConceptViewModel.summary, draft_law_id = pConceptViewModel.draft_law_id, investigator_id = pConceptViewModel.investigator_id, bibliography = pConceptViewModel.bibliography, date_created = DateTime.Now, user_id_created = pConceptViewModel.user_id_created, concept_status_id = 1, pdf_path = pConceptViewModel.pdf_path, hash = Guid.NewGuid() }; //oconcepts.tags = oRepositorioTag.TagsByfilters(pConceptViewModel.tag_ids); oconcepts = oRepositorio.Add(oconcepts); //oUnitOfWork.SaveChanges(); foreach (int tag_id in pConceptViewModel.tag_ids) { concepts_tags oconcepts_tags = new concepts_tags { concept_id = oconcepts.concept_id, tag_id = tag_id, date_created = DateTime.Now, user_id_created = pConceptViewModel.user_id_created }; oRepositorioConceptTag.Add(oconcepts_tags); } oUnitOfWork.SaveChanges(); scope.Complete(); pConceptViewModel.concept_id = oconcepts.concept_id; } }
//Registra un nuevo concepto public ResponseViewModel Register(ConceptViewModel model) { //variables var _result = new ResponseViewModel(); DateTime now = DateTime.Today; try { //map entity var entity = Map.ViewModelToEntity(model); //Crear registro var respuesta = Repository.Register(entity); //valida la respuesta if (respuesta != null) { List <ConceptViewModel> _list = new List <ConceptViewModel>(); _list.Add(Map.EntityToViewModel(entity)); _result.Message = string.Format("Se ha creado el concepto {0}", entity.Nombre); _result.Data = _list.OfType <object>().ToList(); _result.Success = true; } else { _result.Message = "Ha ocurrido un error"; _result.Success = false; } } catch (Exception ex) { _result.Message = ex.Message; _result.Success = false; } return(_result); }
public ConceptView() { this.InitializeComponent(); conceptviewmodel = new ConceptViewModel(); DataContext = conceptviewmodel; }