public CountryApiModel Get(int id) { CountryBusinessLogic _business = new CountryBusinessLogic(); CountryApiModel country = ApiTranslators.Translate <CountryDTO, CountryApiModel>(_business.GetById(id)); return(country); }
public MessageApiModel Post(MessageApiModel mess) { var result = _business.CreateMessage(ApiTranslators.Translate <MessageApiModel, MessageDTO>(mess)); EasyShoppingHub.PushToUser(result.Sent, result, null); return(ApiTranslators.Translate <MessageDTO, MessageApiModel>(result)); }
public ProductApiViewModel GetDetail(int id) { ProductApiViewModel product = ApiTranslators.Translate <ProductViewDTO, ProductApiViewModel>(_business.GetById(id)); if (product != null) { return(product); } return(null); }
public IHttpActionResult Get() { var districts = ApiTranslators.Translate <DistrictDTO, DistrictApiModel>(_business.GetAll()); if (districts.Count() > 0) { return(Ok(districts)); } return(BadRequest()); }
public IHttpActionResult Get(int id) { var district = ApiTranslators.Translate <DistrictDTO, DistrictApiModel>(_business.GetById(id)); if (district != null) { return(Ok(district)); } return(BadRequest()); }
public IHttpActionResult Get() { IEnumerable <ProvinceApiModel> provinces = ApiTranslators.Translate <ProvinceDTO, ProvinceApiModel>(_business.GetAll()); if (provinces.Count() > 0) { return(Ok(provinces)); } return(BadRequest()); }
public IHttpActionResult Get(int id) { ProvinceApiModel province = ApiTranslators.Translate <ProvinceDTO, ProvinceApiModel>(_business.GetById(id)); if (province != null) { return(Ok(province)); } return(BadRequest()); }
// PUT api/values/ //[Authorize(Roles = Roles.Admin)] public IHttpActionResult Put([FromBody] AddUserModel value) { var identity = (ClaimsIdentity)User.Identity; var name = identity.Claims.Where(x => x.Type == ClaimTypes.Name).Single().Value; UserDTO user = ApiTranslators.Translate <AddUserModel, UserDTO>(value); if (!_business.Update(user)) { return(InternalServerError()); } return(Ok()); }
public IHttpActionResult GetUser() { try { var identity = (ClaimsIdentity)User.Identity; var name = identity.Claims.Where(x => x.Type == ClaimTypes.Name).Single().Value; return(Ok(ApiTranslators.Translate <UserDTO, UserApiModel>(_business.GetByName(name).Result))); } catch { return(null); } }
public IEnumerable <ProductApiModel> GetApproveList(int id) { try { var identity = (ClaimsIdentity)User.Identity; var name = identity.Claims.Where(x => x.Type == ClaimTypes.Name).Single().Value; var list = ApiTranslators.Translate <ProductDTO, ProductApiModel>(_business.GetApproveList(id)); return(list); } catch { return(null); } }
public IHttpActionResult Put([FromBody] ProductApiModel data) { try { var identity = (ClaimsIdentity)User.Identity; var name = identity.Claims.Where(x => x.Type == ClaimTypes.Name).Single().Value; var result = _business.Edit(ApiTranslators.Translate <ProductApiModel, ProductDTO>(data), name); return(Ok(result)); } catch { return(BadRequest()); } }
public IEnumerable <StoreApiModel> GetByUserId() { try { var identity = (ClaimsIdentity)User.Identity; var name = identity.Claims.Where(x => x.Type == ClaimTypes.Name).Single().Value; return(ApiTranslators.Translate <StoreDTO, StoreApiModel>(_business.GetByUserId(name).Result)); } catch (Exception e) { Console.WriteLine(e.StackTrace); return(null); } }
public IHttpActionResult BuyPackage([FromBody] ShipperDetailApiModel data) { try { var identity = (ClaimsIdentity)User.Identity; var name = identity.Claims.Where(x => x.Type == ClaimTypes.Name).Single().Value; var result = _business.BuyPackage(ApiTranslators.Translate <ShipperDetailApiModel, ShipperDetailDTO>(data), name); return(Ok(result)); } catch { return(InternalServerError()); } }
//POST api/values public UserApiModel Post([FromBody] AddUserModel user) { HttpRequestMessage request = this.Request; if (!request.Content.IsMimeMultipartContent()) { } UserDTO userdto = ApiTranslators.Translate <AddUserModel, UserDTO>(user); UserApiModel newuser = ApiTranslators.Translate <UserDTO, UserApiModel>(_business.Register(userdto).Result); //UserApiModel newuser = ApiTranslators.Translate<UserDTO, UserApiModel>(); if (newuser != null) { return(newuser); } return(null); }
public StoreApiModel Post([FromBody] StoreApiModel store) { try { //idenity user var identity = (ClaimsIdentity)User.Identity; var name = identity.Claims.Where(x => x.Type == ClaimTypes.Name).Single().Value; //identity user/ store.ModifiedUser = name; store.UserName = name; var newstore = _business.CreateStore(ApiTranslators.Translate <StoreApiModel, StoreDTO>(store)); return(ApiTranslators.Translate <StoreDTO, StoreApiModel>(newstore)); } catch { return(null); } }
public IHttpActionResult Put([FromBody] StoreApiModel store) { try { var identity = (ClaimsIdentity)User.Identity; var name = identity.Claims.Where(x => x.Type == ClaimTypes.Name).Single().Value; var result = _business.Put(ApiTranslators.Translate <StoreApiModel, StoreDTO>(store), name); if (result) { return(Ok(result)); } else { return(BadRequest()); } } catch { return(BadRequest("false")); } }
public IHttpActionResult Post([FromBody] ProductApiModel data) { try { var identity = (ClaimsIdentity)User.Identity; var name = identity.Claims.Where(x => x.Type == ClaimTypes.Name).Single().Value; ProductDTO newproduct = _business.Add(ApiTranslators.Translate <ProductApiModel, ProductDTO>(data), name); ProductApiModel newProduct = ApiTranslators.Translate <ProductDTO, ProductApiModel>(newproduct); if (newProduct.StatusID == 2) { } if (newProduct != null) { return(Ok(newProduct)); } return(BadRequest()); } catch { return(BadRequest()); } }
public IHttpActionResult GetAll(int id) { var result = ApiTranslators.Translate <ShipperDetailDTO, ShipperDetailApiModel>(_business.GetAll(id, 10)); return(Ok(result)); }
public IHttpActionResult Put([FromBody] RecruitmentApiModel data) { var result = _business.Update(ApiTranslators.Translate <RecruitmentApiModel, RecruitmentDTO>(data)); return(Ok(result)); }
public IEnumerable <UserApiModel> Get() { //IEnumerable<UserApiModel> userlist = UserTranslator.ToUserApi(_business.GetAll()); //System.Diagnostics.Debugger.Launch(); return(ApiTranslators.Translate <UserDTO, UserApiModel>(_business.GetAll())); }
public UserApiModel GetDetail(int id) { UserApiModel user = ApiTranslators.Translate <UserDTO, UserApiModel>(_business.GetByID(id)); return(user); }
public StoreApiModel Get(int id) { return(ApiTranslators.Translate <StoreDTO, StoreApiModel>(_business.GetById(id))); }
public IEnumerable <StoreApiModel> Search(string id) { return(ApiTranslators.Translate <StoreDTO, StoreApiModel>(_business.GetByName(id))); }
public async Task <UserApiModel> Get(string username) { UserDTO user = await _business.GetByName(username); return(ApiTranslators.Translate <UserDTO, UserApiModel>(user)); }
public IEnumerable <ProductTypeApiModel> Get() { return(ApiTranslators.Translate <ProductTypeDTO, ProductTypeApiModel>(_business.GetAll())); }
// [Authorize(Roles = "CountryGet")] // OAuthorize(Name="CountryGet") => Filter => 404 public IEnumerable <CountryApiModel> Get() { CountryBusinessLogic _business = new CountryBusinessLogic(); return(ApiTranslators.Translate <CountryDTO, CountryApiModel>(_business.GetAll())); }