Ejemplo n.º 1
0
        public CountryApiModel Get(int id)
        {
            CountryBusinessLogic _business = new CountryBusinessLogic();
            CountryApiModel      country   = ApiTranslators.Translate <CountryDTO, CountryApiModel>(_business.GetById(id));

            return(country);
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
        public ProductApiViewModel GetDetail(int id)
        {
            ProductApiViewModel product = ApiTranslators.Translate <ProductViewDTO, ProductApiViewModel>(_business.GetById(id));

            if (product != null)
            {
                return(product);
            }
            return(null);
        }
Ejemplo n.º 4
0
        public IHttpActionResult Get()
        {
            var districts = ApiTranslators.Translate <DistrictDTO, DistrictApiModel>(_business.GetAll());

            if (districts.Count() > 0)
            {
                return(Ok(districts));
            }
            return(BadRequest());
        }
Ejemplo n.º 5
0
        public IHttpActionResult Get(int id)
        {
            var district = ApiTranslators.Translate <DistrictDTO, DistrictApiModel>(_business.GetById(id));

            if (district != null)
            {
                return(Ok(district));
            }
            return(BadRequest());
        }
Ejemplo n.º 6
0
        public IHttpActionResult Get()
        {
            IEnumerable <ProvinceApiModel> provinces = ApiTranslators.Translate <ProvinceDTO, ProvinceApiModel>(_business.GetAll());

            if (provinces.Count() > 0)
            {
                return(Ok(provinces));
            }
            return(BadRequest());
        }
Ejemplo n.º 7
0
        public IHttpActionResult Get(int id)
        {
            ProvinceApiModel province = ApiTranslators.Translate <ProvinceDTO, ProvinceApiModel>(_business.GetById(id));

            if (province != null)
            {
                return(Ok(province));
            }
            return(BadRequest());
        }
Ejemplo n.º 8
0
        // 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());
        }
Ejemplo n.º 9
0
 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);
     }
 }
Ejemplo n.º 10
0
 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);
     }
 }
Ejemplo n.º 11
0
 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());
     }
 }
Ejemplo n.º 12
0
 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);
     }
 }
Ejemplo n.º 13
0
 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());
     }
 }
Ejemplo n.º 14
0
        //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);
        }
Ejemplo n.º 15
0
 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);
     }
 }
Ejemplo n.º 16
0
 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"));
     }
 }
Ejemplo n.º 17
0
 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());
     }
 }
Ejemplo n.º 18
0
        public IHttpActionResult GetAll(int id)
        {
            var result = ApiTranslators.Translate <ShipperDetailDTO, ShipperDetailApiModel>(_business.GetAll(id, 10));

            return(Ok(result));
        }
Ejemplo n.º 19
0
        public IHttpActionResult Put([FromBody] RecruitmentApiModel data)
        {
            var result = _business.Update(ApiTranslators.Translate <RecruitmentApiModel, RecruitmentDTO>(data));

            return(Ok(result));
        }
Ejemplo n.º 20
0
 public IEnumerable <UserApiModel> Get()
 {
     //IEnumerable<UserApiModel> userlist = UserTranslator.ToUserApi(_business.GetAll());
     //System.Diagnostics.Debugger.Launch();
     return(ApiTranslators.Translate <UserDTO, UserApiModel>(_business.GetAll()));
 }
Ejemplo n.º 21
0
        public UserApiModel GetDetail(int id)
        {
            UserApiModel user = ApiTranslators.Translate <UserDTO, UserApiModel>(_business.GetByID(id));

            return(user);
        }
Ejemplo n.º 22
0
 public StoreApiModel Get(int id)
 {
     return(ApiTranslators.Translate <StoreDTO, StoreApiModel>(_business.GetById(id)));
 }
Ejemplo n.º 23
0
 public IEnumerable <StoreApiModel> Search(string id)
 {
     return(ApiTranslators.Translate <StoreDTO, StoreApiModel>(_business.GetByName(id)));
 }
Ejemplo n.º 24
0
        public async Task <UserApiModel> Get(string username)
        {
            UserDTO user = await _business.GetByName(username);

            return(ApiTranslators.Translate <UserDTO, UserApiModel>(user));
        }
Ejemplo n.º 25
0
 public IEnumerable <ProductTypeApiModel> Get()
 {
     return(ApiTranslators.Translate <ProductTypeDTO, ProductTypeApiModel>(_business.GetAll()));
 }
Ejemplo n.º 26
0
        // [Authorize(Roles = "CountryGet")] // OAuthorize(Name="CountryGet") => Filter => 404
        public IEnumerable <CountryApiModel> Get()
        {
            CountryBusinessLogic _business = new CountryBusinessLogic();

            return(ApiTranslators.Translate <CountryDTO, CountryApiModel>(_business.GetAll()));
        }