コード例 #1
0
        //public async Task<ICommandResult> Handle(VendorRegisterCommand mesage)
        //{
        //    try
        //    {
        //        Vendor vendor = new Vendor(mesage.Version);
        //        vendor.Register(mesage);
        //        await _vendorService.AddToDb(vendor);
        //        ICommandResult result = new CommandResult()
        //        {
        //            Message = "",
        //            ObjectId = vendor.Id,
        //            Status = CommandResult.StatusEnum.Sucess
        //        };
        //        return result;
        //    }
        //    catch (Exception e)
        //    {
        //        e.Data["Param"] = mesage;
        //        ICommandResult result = new CommandResult()
        //        {
        //            Message = e.Message,
        //            Status = CommandResult.StatusEnum.Fail
        //        };
        //        return result;
        //    }
        //}

        public async Task <ICommandResult> Handle(VendorAddCommand mesage)
        {
            try
            {
                Vendor vendor = new Vendor(mesage.Version);
                vendor.Add(mesage);
                await _vendorService.AddToDb(vendor);

                ICommandResult result = new CommandResult()
                {
                    Message  = "",
                    ObjectId = vendor.Id,
                    Status   = CommandResult.StatusEnum.Sucess
                };
                return(result);
            }
            catch (Exception e)
            {
                e.Data["Param"] = mesage;
                ICommandResult result = new CommandResult()
                {
                    Message = e.Message,
                    Status  = CommandResult.StatusEnum.Fail
                };
                return(result);
            }
        }
コード例 #2
0
        private Vendor CreateCityVendor()
        {
            var vendor  = new Vendor(Description.PeopleNames.Random());
            var weapons = Items.OfType <ItemWeapon>();

            for (int i = 0; i < 2; i++)
            {
                var weapon = weapons.ElementAt(Random.Next(weapons.Count()));
                vendor.Add(weapon);
            }
            return(vendor);
        }
コード例 #3
0
        public ActionResult Create(string orderInfo, int vendorId, string orderPayment, string orderDate, string orderLocation)
        {
            Dictionary <string, object> model = new Dictionary <string, object>();
            Vendor foundVendor = Vendor.Find(vendorId);
            Order  newOrder    = new Order(orderInfo, orderPayment, orderDate, orderLocation);

            foundVendor.Add(newOrder);
            List <Order> venOrders = foundVendor.Orders;

            model.Add("orders", venOrders);
            model.Add("vendor", foundVendor);
            return(View("Show", model));
        }
コード例 #4
0
        private void Insert_Vendor()
        {
            var repository = new Vendor();

            if (repository.Add(get_Data_From_Form()))
            {
                this.ShowSuccessfulNotification("Vendor added successfully.");
                clear_form();
                Load_Data_Grid();
            }
            else
            {
                this.ShowErrorNotification("Error occured.");
            }
        }