public async Task <TitleDto> PutTitle(int id, TitleDto model) { var url = CRMApiUri + "/Title/" + id; var result = await PutRequestToApi(url, model); return(result); }
public async Task <BaseEntity> SaveAndReturnEntityAsync(TitleDto entityDto) { var entity = _mapper.Map <Title>(entityDto); var result = await _repository.SaveAndReturnEntityAsync(entity); return(result); }
public async Task <TitleDto> PostTitle(TitleDto model) { var url = CRMApiUri + "/Title"; var result = await PostRequestToApi(url, model); return(result); }
/// <summary> /// 購買稱號系統 /// </summary> /// <param name="buy"></param> /// <returns></returns> public string BuyTitle(BuyTitle buy) { ForumMembers user = _users.GetAll2().FirstOrDefault(u => u.UserId.ToString() == buy.UserId); TitleDto price = _titles.GetAll2().Select(x => new TitleDto() { TitleId = x.TitleId, TitleName = x.TitleName, Price = decimal.Parse(x.Price.ToString()) }).FirstOrDefault(t => t.TitleName == buy.TitleId); if (user.Points > price.Price) { user.Points = user.Points - price.Price; _users.Update(user); _users.SaveContext(); MemberTitle newtitle = new MemberTitle { UserId = Guid.Parse(buy.UserId), HasTitleId = price.TitleId }; _usertitle.Create(newtitle); _usertitle.SaveContext(); return("稱號購買完成"); } return("點數不足,請加把勁"); }
private static Title GetTitleFromDto(TitleDto dto) { return(new Title { Id = dto.Id, Text = dto.Text }); }
public async Task <IActionResult> Put(int id, [FromBody] TitleDto title) { if (id == 0 || title.Id == 0) { return(StatusCode(StatusCodes.Status400BadRequest, "Id needs to be greater than 0.")); } return(await SaveAndReturnEntityAsync(async() => await _titleService.SaveAndReturnEntityAsync(title))); }
public async Task <IActionResult> Post([FromBody] TitleDto title) { if (title.Id != 0) { return(StatusCode(StatusCodes.Status400BadRequest, "Identity insert is not permitted.")); } return(await SaveAndReturnEntityAsync(async() => await _titleService.SaveAndReturnEntityAsync(title))); }
public async Task <IActionResult> Create([FromBody] TitleDto model) { var modelForAdd = _Mapper.Map <Title>(model); _Uow.Titles.Add(modelForAdd); if (await _Uow.Save()) { return(Ok(new { Status = true, Message = "Successfully Added" })); } return(BadRequest()); }
public async Task <IActionResult> Update([FromBody] TitleDto model) { var isExist = await _Uow.Titles.FirstOrDefault(p => p.Id == model.Id); if (isExist == null) { return(NotFound("Could't Found This Title")); } var modelForUpdate = _Mapper.Map <Title>(model); _Uow.Titles.Update(modelForUpdate); if (await _Uow.Save()) { return(Ok(new { Status = true, Message = "Successfully Updated" })); } return(BadRequest()); }
public IActionResult Save(TitleDto model) { UpdateAuditInformation(model); if (!ModelState.IsValid) { GetStateSettings(ViewState.Write); return(PartialView("Edit", model)); } model = model.Id > 0 ? _lookupFacadeApiClient.PutTitle(model.Id, model).Result : _lookupFacadeApiClient.PostTitle(model).Result; if (!string.IsNullOrWhiteSpace(model.ErrorMessage)) { return(PartialView("Edit", model)); } return(Json(new { message = model.SuccessMessage })); }
public TitleDto MapToTitleDto(Title title) { var titleDto = new TitleDto { Id = title.Id, Vin = title.Vin, TitleState = title.TitleState, VehYr = title.VehYr, VehMake = title.VehMake, VehModel = title.VehModel, NewVeh = title.NewVeh, TitleIssueDt = title.TitleIssueDt, EntryDt = title.EntryDt, UserId = title.UserId, RecDt = title.RecDt, RecMethod = title.RecMethod, InitialLocation = title.InitialLocation, CustFName = title.CustFName, CustLName = title.CustLName, CustAddr1 = title.CustAddr1, CustAddr2 = title.CustAddr2, CustCity = title.CustCity, CustState = title.CustState, CustZip = title.CustZip, CustPhone = title.CustPhone, CustPhone2 = title.CustPhone2, CustEmail = title.CustEmail, CustFName2 = title.CustFName2, CustLName2 = title.CustLName2, CustFName3 = title.CustFName3, CustLName3 = title.CustLName3, SentToDmvDt = title.SentToDmvDt, SentBackToLhDlrDt = title.SentBackToLhDlrDt, TitleRecievedFromType = title.TitleRecievedFromType, SentUserId = title.SentUserId, CountyId = title.CountyId, FollowUp = title.FollowUp, IsDeleted = title.IsDeleted, Interactions = title.Interactions, Transfers = title.Transfers }; return titleDto; }
public async Task <TitleDto> PutTitle(int id, TitleDto model) { return(await _titleApiClient.PutTitle(id, model)); }
public async Task <TitleDto> PostTitle(TitleDto model) { return(await _titleApiClient.PostTitle(model)); }
public async Task <int> SaveAsync(TitleDto entityDto) { var result = await SaveAndReturnEntityAsync(entityDto); return(result.Id); }