/// <summary> /// 添加错误日志 /// </summary> /// <param name="logDto"></param> /// <returns></returns> public async Task <int> AddErrorLogAsync(ErrorLogDto logDto) { var logEntity = logDto.MapTo <ErrorLogEntity>(); baseService.Add(logEntity); var result = await baseService.SaveAsync(); return(result); }
public TViewModel Add(TViewModel model) { var validate = ValidateInsert(model); if (!validate.IsValid) { return(validate); } var entity = _mapper.Map <T>(model); var result = _baseService.Add(entity); _uow.Commit(); return(_mapper.Map <TViewModel>(result)); }
public async Task <IActionResult> AddStep1(NewPublicationViewModel model, IFormFile File) { if (!ModelState.IsValid) { return(RedirectToAction("Index")); } model.NewPublication.Contributor = new Contributor(model.SelectedAuthorId); foreach (int id in model.SelectedAuthorIds) { model.NewPublication.Contributor.Contributors.Add(new Contributor_Author(id, AuthorRoleEnum.Secondary)); } model.NewPublication.Document = new Document(); model.NewPublication.Document.FileName = File.FileName; model.NewPublication.Document.DocType = (DocumentTypeEnum)model.PublicationType; using (var memoryStream = new MemoryStream()) { await File.CopyToAsync(memoryStream); model.NewPublication.Document.Content = memoryStream.ToArray(); } model.NewPublication.AddedBy = User.Identity.Name; int i = await _pubService.Add(model.NewPublication); return(RedirectToAction("Index")); }
public async Task <IActionResult> AddPublisher([FromBody] PublisherVM publisher) { IEnumerable <Publisher> pubs = await _publisherService.GetAll(); bool exist = false; //PublisherVM pub = JsonConvert.DeserializeObject<PublisherVM>(publisher); PublisherVM pub = publisher; if (pubs.Any()) { foreach (Publisher p in pubs) { if (p.Name.ToLower() == pub.Name.ToLower() && p.Location.ToLower() == pub.Location.ToLower()) { exist = true; } } } if (!exist) { await _publisherService.Add(new Publisher(pub.Name, pub.Location)); } pubs = await _publisherService.GetAll(); List <PublisherViewModel> pubList = new List <PublisherViewModel>(); foreach (Publisher p in pubs) { pubList.Add(new PublisherViewModel(p.Id, p.Name, p.Location)); } return(Json(pubList)); }
public async Task <IActionResult> Add([Bind("Title,Initials,FullName,Surname,Qualification,DepartmentName")] Author auth, IFormFile file) { if (ModelState.IsValid) { try { if (file != null && file.Length > 0) { var fileName = Path.GetFileName(file.FileName); var filePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot\\images\\propics", fileName); using (var fileSteam = new FileStream(filePath, FileMode.Create)) { await file.CopyToAsync(fileSteam); } auth.ProfilePicture = fileName; } Author author = new Author(auth.FullName, auth.Surname, auth.Title, auth.Initials, auth.Qualification, auth.DepartmentName); int id = await _authorService.Add(auth); return(RedirectToAction(nameof(Profile), new { authId = id })); } catch (Exception ex) { } } return(View(auth)); }
public async Task <TEntityDTO> Add(TEntityDTO obj) { TEntity entity = _mapper.Map <TEntity>(obj); TEntity entityCreated = await _service.Add <TValidator>(entity); return(_mapper.Map <TEntityDTO>(entityCreated)); }
public async Task <IActionResult> AddProduct(ProductAddDto model, IFormFile Image) { if (ModelState.IsValid) { if (Image != null) { var images = Path.GetExtension(Image.FileName); string guid = Guid.NewGuid() + images; var addimages = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/image/" + guid); using (var stream = new FileStream(addimages, FileMode.Create)) { await Image.CopyToAsync(stream); } _productService.Add(_mapper.Map <Product>(model)); return(RedirectToAction("Index")); } } return(View(model)); }
public IActionResult Post(User user) { var MappedUser = _mapper.Map <User>(_userRepository.Add(user)); _userRepository.Save(); return(new CreatedResult(MappedUser.Id.ToString(), user)); }
public TViewModel Add(T model) { var result = _baseService.Add(model); _uow.Commit(); return(result.MapTo <TViewModel>()); }
public IActionResult AddDept(string pid, string name, bool isParent) { IBaseService <Department, Guid> deptBaseService = _deptManageService as IBaseService <Department, Guid>; Guid guidPid; var enCode = string.Empty; if (pid == null) //添加的是根节点 { guidPid = defaulGuid; enCode = "0."; } else { guidPid = new Guid(pid); var pEnCode = deptBaseService.Get(x => x.Id == guidPid).Select(x => x.EnCode).FirstOrDefault(); enCode = pEnCode + (deptBaseService.Get(x => x.Pid == guidPid).Count() + 1).ToString() + "."; } Department department = new Department { Name = name, Pid = guidPid, EnCode = enCode, CreateUserId = UserInfoSession.UserId, CreationTime = DateTime.Now, IsParent = isParent, }; var code = deptBaseService.Add(department); if (code == 1) { return(AddSuccessData(department.Id)); } return(FailedMsg("添加部门失败")); }
public IActionResult Post(PosteadorDTO post) { var MappedPost = _mapper.Map <Posteador>(post); _posteadorRepository.Add(MappedPost); _posteadorRepository.Save(); return(new CreatedResult(MappedPost.Id.ToString(), MappedPost)); }
public TModel Add(TModel model) { var entity = AutoMapper.Mapper.Map <TEntity>(model); BaseService.Add(entity); BaseService.Save(); return(AutoMapper.Mapper.Map <TModel>(entity)); }
public virtual JsonResult Add(T model) { if (BaseService.Add(model) > 0) { return(Json(""));//todo 制定返回规范 } return(Json("")); }
public async Task <int> Handle(CreatePageCommand request, CancellationToken cancellationToken) { var entity = new Dev.Domain.Page() { PageName = request.PageName, PageDesc = request.PageDesc, PageText = request.PageText }; return(await _service.Add(entity)); }
public IActionResult Create([FromBody] CreateUserModel user) { if (user == null) { return(NotFound()); } return(Execute(() => _baseUserService.Add <CreateUserModel, UserModel, UserValidator>(user))); }
public IActionResult Create([FromBody] User user) { if (user == null) { return(NotFound()); } return(Execute(() => _baseUserService.Add <UsuarioValidator>(user).Id)); }
public virtual async Task <IActionResult> Create(TEntity entity) { if (ModelState.IsValid) { await _Service.Add(entity); return(RedirectToAction(nameof(Index))); } return(View(entity)); }
public IActionResult AddCategory(CategoryAddDto model) { if (ModelState.IsValid) { _categoryService.Add(_mapper.Map <Category>(model)); return(RedirectToAction("Index")); } return(View(model)); }
public IActionResult Post(TEntity entity) { var result = _baseService.Add(entity); if (result.MISACode == ApplicationCore.Enums.MISACode.NotValid) { return(BadRequest(result.data)); } return(Ok(result)); }
public async Task <IHttpActionResult> Add(IndexDepartamentViewModel model) { if (!ModelState.IsValid) { return(BadRequest()); } await _service.Add(_mapper.Map <DepartamentBll>(model)); return(Ok()); }
public virtual TViewModel Add(TViewModel viewModel) { viewModel.Id = viewModel.Id == Guid.Empty ? Guid.NewGuid() : viewModel.Id; var entity = AutoMapper.Mapper.Map <TEntity>(viewModel); _baseService.Add(entity); viewModel.Id = entity.Id; return(viewModel); }
public IActionResult Create([FromBody] Category category) { Console.WriteLine("\n\ncategory post controleris\n\n"); var _category = _baseService.Add(category); if (_category == null) { return(BadRequest()); } return(CreatedAtRoute("GetCategory", new { id = _category.Id }, category)); }
public IActionResult Create([FromBody] Recipe recipe) { Console.WriteLine("route turinys"); var _recipe = _baseService.Add(recipe); if (_recipe == null) { return(BadRequest()); } return(CreatedAtRoute("GetRecipe", new { id = _recipe.Id }, recipe)); }
public IActionResult POST(T model) { if (!ModelState.IsValid) { return(BadRequest("Bhai please sob field fill up koren")); } var add = service.Add(model); return(Ok(add)); }
public IActionResult Add(Brand brand) { var result = _brandService.Add(brand); if (result.Success) { return(Ok(result)); } return(BadRequest(result)); }
public ActionResult Create(CarViewModel car) { if (ModelState.IsValid) { _carHandler.Add(car.CreateCarDomain()); _carHandler.Commit(); return(RedirectToAction("Index")); } return(View(car)); }
public void Add(T entidade) { try { _serviceBase.Add(entidade); } catch (Exception ex) { throw ex; } }
protected ActionResult Add(TId model) { if (!ModelState.IsValid) { throw new Exception("Valores Inválidos"); } var entity = MapperHelper.Map <TId, T>(model); var response = _service.Add(entity); return(Ok(response)); }
//public virtual IHttpActionResult Get(BaseRequestModel request) //{ // TEntity entity = null; // if (request.IsGuid) // entity = Service.GetById(Guid.Parse(request.Id)); // else // entity = Service.GetById(request.Id); // return Ok(entity); //} public virtual IHttpActionResult Post(TEntity entity) { if (!ModelState.IsValid) { return(BadRequest()); } var add = Service.Add(entity); return(Ok(add)); }
public IActionResult Create([FromBody] TEntity entity, [FromRoute] long categoryId) { Console.WriteLine("route turinys" + categoryId); var _entity = _baseService.Add(entity); if (_entity == null) { return(BadRequest()); } return(CreatedAtRoute("GetRecipe", new { id = _entity.Id }, entity)); }