public IActionResult Index() { AppService app = new AppService(); //sehvdir chunki ozunde business logica saxlayir . Yeni Programin life syscleni teyin eden methodlar var Student s = new Student(); appService.Add(new Student()); //duzdur cunki ozunde hec bir business logic saxlamir return(View()); }
public virtual async Task <IActionResult> Post([FromBody] T t) { if (ModelState.IsValid) { sw.Start(); var retorno = await _appService.Add(t); sw.Stop(); if (retorno != null && !retorno.ValidationResult.IsValid) { return(BadRequest(new { success = false, data = retorno.ValidationResult.ToString(), tempoProcessamento = TempoProcessamento(sw) })); } return(retorno != null ? Ok(new { success = true, data = retorno, tempoProcessamento = TempoProcessamento(sw) }) : (IActionResult)NoContent()); } return(BadRequest(t)); }
public async Task <Result> Modify(AppDto dto, string opt) { try { var files = Request.Form.Files; if (files.Count > 0) { var stream = files[0].OpenReadStream(); // var fileStream = new FileStream(name, FileMode.Open, FileAccess.Read); var br = new BinaryReader(stream); var image = br.ReadBytes((int)stream.Length); var memory = new MemoryStream(image) { Position = 0 }; var documentManager = ObjectContainer.Resolve <IDocumentManager>(); var streamId = documentManager.Upload($"Picture_{DateTime.Now.ToString19()}", memory); stream.Close(); br.Close(); memory.Close(); dto.Icon = streamId; } return(await Task.Run(() => { dto.OperateDate = DateTime.Now; dto.Operator = LoginInfo.Id; if (opt == "add")//新增 { dto.CreateDate = DateTime.Now; dto.Status = 1; dto.Creator = LoginInfo.Id; return _appService.Add(dto, LoginInfo.Role); } //修改 return _appService.Update(dto); })); } catch (Exception e) { Logger.Error("错误", e); return(new Result { Status = false }); } }
public virtual async Task <IActionResult> Post([FromBody] T t, ApiVersion apiVersion) { if (ModelState.IsValid) { sw.Start(); var retorno = await _appService.Add(t); sw.Stop(); //if (retorno != null && !retorno.ValidationResult.IsValid) //{ // return BadRequest(new // { // data = retorno.ValidationResult.ToString(), // tempoProcessamento = TempoProcessamento(sw) // }); //} //return CreatedAtAction(nameof(Get), new { apiVersion = apiVersion.ToString(), id = retorno.Identificador }, retorno); return(retorno != null ? CreatedAtAction( nameof(Get), new { apiVersion = apiVersion.ToString(), id = retorno.Identificador }, new { data = retorno, tempoProcessamento = TempoProcessamento(sw) }) : (IActionResult)NoContent()); } return(BadRequest(t)); }
public virtual IActionResult Add([FromBody] TInputEntityDto entityDto) { var entity = _baseAppService.Add(entityDto); return(StatusCode(StatusCodes.Status201Created, entity)); }