public ActionResult <AddressReadFullDto> GetAddress(int id)
        {
            var address = _addressService.Get(id);

            if (address == null)
            {
                return(NotFound());
            }
            return(Ok(_mapper.Map <AddressReadFullDto>(address)));
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: diwangtseb/RestFulapi
        static void Main(string[] args)
        {
            using (ChannelFactory <IAddress> channelFactory = new ChannelFactory <IAddress>("addressService"))
            {
                IAddress iAddress = channelFactory.CreateChannel();
                Address  address  = iAddress.Get("210.75.225.254");

                if (address != null)
                {
                    Console.WriteLine(string.Format("IP来自{0},{1}", address.Province, address.City));
                }
            }
        }
コード例 #3
0
ファイル: AdminController.cs プロジェクト: Aakashbist/Deals
        public ActionResult CreateStore(StoreViewModel store, IEnumerable <HttpPostedFileBase> files)
        {
            // to create dropdownlist

            StoreViewModel dropdown = DropdownforCompany();

            try
            {
                if (Session[KeyList.SessionKeys.UserID] != null)
                {
                    var userId = Session[KeyList.SessionKeys.UserID].ToString();
                    if (ModelState.IsValid)
                    {
                        if (Checknumber(store.Contact) == false)
                        {
                            ViewBag.message = "Please Add Number without +64 or 0";
                            return(View(dropdown));
                        }
                        var addressss = addressService.Get(a => a.City == store.City && a.Street == store.Street && a.Country == store.Country).SingleOrDefault();
                        if (addressss == null)
                        {
                            bool Image = files.IsValidImageList(false);
                            if (Image == true)
                            {
                                foreach (var item in files)
                                {
                                    var path = item.SaveImageFile();

                                    Store _store = new Store
                                    {
                                        StoreName           = store.StoreName,
                                        UserId              = Convert.ToInt32(userId),
                                        Contact             = "+64" + store.Contact,
                                        IdentificationImage = path,
                                        CompanyId           = store.CompanyId,
                                        IsValid             = false,
                                        IsDeleted           = false,
                                    };

                                    int     id      = storeService.CreateStore(_store);
                                    Address address = new Address
                                    {
                                        Street  = store.Street,
                                        City    = store.City,
                                        Country = store.Country,
                                        StoreId = id,
                                    };
                                    addressService.CreateAddress(address);
                                }
                            }
                            else
                            {
                                ViewBag.message = "Image is required and should only have .pdf,.jpeg,.jpg,.gif";
                                return(View(dropdown));
                            }
                        }
                        Logs GenerateLog = new Logs();
                        GenerateLog.CreateLog(Convert.ToInt32(userId), KeyList.LogMessages.CreateStore);
                        return(RedirectToAction("Store"));
                    }
                }

                return(View(dropdown));
            }
            catch (Exception e)
            {
                return(View(dropdown));
            }
        }