public ActionResult Edit(Guid id) { var local = _localService.Get(id); var formModel = new LocalFormModel(); PopulateFormModelData(formModel, local); return(View(formModel)); }
public JsonResult Gethistorial(Guid?parent, int page = 1, int limit = 10) { PagedList <EvaluacionDto> items = new PagedList <EvaluacionDto>(); var records = new List <EvaluacionDto>(); long total = 0; if (parent.HasValue) { var parentId = parent.Value; var cadena = _cadenaService.Get(parentId); if (cadena != null) { items = _evaluacionService.GetByCadenaPagedList(cadena.Id, page > 0 ? page - 1 : page, limit); } else { var local = _localService.Get(parentId); if (local != null) { items = _evaluacionService.GetByLocalPagedList(local.Id, page > 0 ? page - 1 : page, limit); } } if (items != null) { records = items.Items; total = items.TotalCount; } } return(Json( new { records, total } , JsonRequestBehavior.AllowGet)); }
public async Task <IHttpActionResult> GetById(Guid id) { LocalDto item = null; try { if (await _authorizationService.AuthorizeAsync(User)) { var local = _localService.Get(id); item = Mapper.Map <Local, LocalDto>(local); } else { var codeResult = new CodeResultStatus(401); return(Ok(codeResult)); } } catch (Exception e) { Console.WriteLine(e); throw; } return(Ok(item)); }
public async Task <IHttpActionResult> Create([FromBody] EvaluacionFormModel formModel) { GenericResult itemResult = null; try { if (await _authorizationService.AuthorizeAsync(User)) { if (ModelState.IsValid) { var evaluacion = new Evaluacion { NombreMIC = formModel.NombreMIC, NombreRGM = formModel.NombreRGM, PosicionMIC = _evaluacionService.GetPosicion(formModel.Posicion), TipoVisita = formModel.TipoVisita, ParteDelDia = formModel.ParteDia, TipoEvaluacion = _evaluacionService.GetTipoEvaluacion(formModel.TipoEvaluacion), Local = _localService.Get(formModel.IdLocal), Estado = _statusService.Online(), FechaEvaluacion = DateTime.Now, HoraEvaluacion = DateTime.Now, ActualizadoEn = DateTime.Now, CreadoEn = DateTime.Now, ActualizadoPor = "admin", CreadoPor = "admin", }; var confirmation = _evaluacionService.SaveOrUpdate(evaluacion); if (confirmation.WasSuccessful) { var respConfirmation = _evaluacionService.CreateRespuestasByEvaluacion(evaluacion.Id); itemResult = GenericResult.Ok(confirmation.Message); var item = confirmation.Value as Evaluacion; itemResult.ReturnValue = new { Id = item.Id }; } else { itemResult = GenericResult.Failure(confirmation.Message); } } } else { var codeResult = new CodeResultStatus(401); return(Ok(codeResult)); } } catch (System.Exception exception) { itemResult = GenericResult.Failure(exception.Message); } return(Ok(itemResult)); }
public async Task <IHttpActionResult> SaveByLocal([FromBody] ImagenLocalFormModel formModel) { GenericResult itemResult = null; try { if (await _authorizationService.AuthorizeAsync(User)) { var imagenLocal = _localService.GetImage(formModel.Id) ?? new ImagenLocal(); if (imagenLocal.Id == Guid.Empty) { imagenLocal.CreadoEn = DateTime.Now; imagenLocal.CreadoPor = User.Identity.Name; } imagenLocal.ActualizadoEn = DateTime.Now; imagenLocal.ActualizadoPor = User.Identity.Name; imagenLocal.Descripcion = !string.IsNullOrEmpty(formModel.Descripcion) ? formModel.Descripcion : ""; imagenLocal.Tipo = formModel.Tipo; imagenLocal.Orden = formModel.Orden; var local = _localService.Get(formModel.LocalId); imagenLocal.Local = local; if (!string.IsNullOrEmpty(formModel.ImagenData)) { var imageBase64 = formModel.ImagenData.Replace("data:image/jpeg;base64,", ""); var imageBytes = Convert.FromBase64String(imageBase64); var imageUrl = _blobImageService.UploadImage(imageBytes, BlobContainers.Locales()); imagenLocal.Imagen = imageUrl; } ActionConfirmation confirmation = _localService.SaveOrUpdateImagen(imagenLocal); if (confirmation.WasSuccessful) { itemResult = GenericResult.Ok(confirmation.Message); var item = confirmation.Value as ImagenLocal; itemResult.ReturnValue = new { Id = item.Id }; } else { itemResult = GenericResult.Failure(confirmation.Message); } } } catch (Exception exception) { itemResult = GenericResult.Failure(exception.Message); } return(Ok(itemResult)); }
public IHttpActionResult Get(int page) { return(Ok(_localService.Get(0))); }