Пример #1
0
        public StoreDTO CreateStore(StoreDTO store)
        {
            var userId = _userbusiness.GetByName(store.UserName).Result.ID;

            store.CreatedDate  = System.DateTime.Now;
            store.ModifiedDate = System.DateTime.Now;
            store.StatusID     = WAITINGFORAPPROVE;
            store.UserID       = userId;
            store.CityId       = _city.GetByName(store.City).Id;
            store.CountryId    = _country.GetByName(store.Country).Id;
            var DisString = store.District.Split('.');

            if (DisString.Length > 1)
            {
                store.DistrictId = _district.GetByName(DisString[1]).Id;
            }
            else if (DisString.Length == 1)
            {
                store.DistrictId = _district.GetByName(DisString[0]).Id;
            }
            store.ModifiedByID = userId;
            store.LimitProduct = PACKAGE1;
            store = _repo.Create(BusinessTranslators.ToStoreEntity(store)).Translate <Store, StoreDTO>();
            return(store);
        }
Пример #2
0
        public bool Put(StoreDTO store, string name)
        {
            var userId = _userbusiness.GetByName(store.UserName).Result.ID;

            store.ModifiedDate = System.DateTime.Now;
            store.CityId       = _city.GetByName(store.City).Id;
            store.CountryId    = _country.GetByName(store.Country).Id;
            var DisString = store.District.Split('.');

            if (DisString.Length > 1)
            {
                store.DistrictId = _district.GetByName(DisString[1]).Id;
            }
            else if (DisString.Length == 1)
            {
                store.DistrictId = _district.GetByName(DisString[0]).Id;
            }
            store.ModifiedByID = userId;
            if (string.IsNullOrEmpty(store.ImgLink))
            {
                store.ImgLink = _repo.FindByID(store.ID).ImgLink;
            }
            var result = _repo.Edit(BusinessTranslators.ToStoreEntity(store));

            return(result);
        }
Пример #3
0
        public bool Update(UserDTO user)
        {
            ClearCache(user.UserName);

            if (_repo.Update(user.ID, BusinessTranslators.Translate <UserDTO, User>(user)))
            {
                return(true);
            }
            return(false);
        }
Пример #4
0
        public void Configuration(IAppBuilder app)
        {
            var config = new HttpConfiguration();

            WebApiConfig.Register(config);
            app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);
            ConfigureAuth(app);
            app.UseWebApi(config);

            BusinessTranslators.Init();
            ApiTranslators.Init();
        }