Exemplo n.º 1
0
 /// <summary>
 /// 停止营业
 /// </summary>
 /// <param name="id">餐厅ID</param>
 /// <returns></returns>
 public IReturn Close(int id)
 {
     M.Supplier supplier = M.RepositoryRegistry.Supplier.FindBy(id);
     if (supplier != null)
     {
         supplier.Close();
         M.RepositoryRegistry.Supplier.Update(supplier);
     }
     return(this.Write("Close", supplier));
 }
Exemplo n.º 2
0
        /// <summary>
        /// 创建餐厅
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public IReturn Add(AddSupplierModel model)
        {
            M.Supplier supplier = model.ToSupplier();
            if (supplier.Validate())
            {
                M.RepositoryRegistry.Supplier.Add(supplier);

                return(this.WriteAndPublishDomainEvent <M.Supplier, AddDomainEvent>("Add", supplier, new AddDomainEvent(supplier.Id, supplier.Name, supplier.Tel, supplier.Address, supplier.CreateDate)));
            }
            return(this.Write("Add", supplier));
        }
Exemplo n.º 3
0
        public static M.Supplier ToSupplier(this AddSupplierModel model, M.Supplier supplier)
        {
            supplier.Name         = model.Name;
            supplier.Tel          = model.Tel;
            supplier.Address      = model.Address;
            supplier.BusinessTime = new M.BusinessTime(model.BusinessTimeStart.ToTime(), model.BusinessTimeEnd.ToTime());

            supplier.Coordinates = new M.Coordinates(model.CoordinatesLongitude, model.CoordinatesLatitude);

            supplier.DeliveryTime = NullHelper.IfNull(model.DeliveryTime, new DeliveryTime[0]).Select(m => m.ToDeliveryTime()).ToArray();

            return(supplier);
        }
Exemplo n.º 4
0
 /// <summary>
 /// 更新餐厅信息
 /// </summary>
 /// <param name="supplierId">餐厅ID</param>
 /// <param name="model">餐厅信息</param>
 /// <returns></returns>
 public IReturn Update(int supplierId, AddSupplierModel model)
 {
     M.Supplier supplier = M.RepositoryRegistry.Supplier.FindBy(supplierId);
     if (supplier != null)
     {
         model.ToSupplier(supplier);
         if (supplier.Validate())
         {
             M.RepositoryRegistry.Supplier.Update(supplier);
         }
     }
     return(this.Write("Update", supplier));
 }
Exemplo n.º 5
0
        public static DetailSupplierModel ToDetailSupplierModel(this M.Supplier model)
        {
            var supplier = new DetailSupplierModel()
            {
                Id             = model.Id,
                Tel            = model.Tel,
                Address        = model.Address,
                Name           = model.Name,
                BusinessStatus = (int)model.CurrentBusinessStatus,
                BusinessTime   = model.BusinessTime.ToBusinessTime(),
                CreateDate     = model.CreateDate,
                DeliveryStatus = model.CurrentDeliveryStatus,
                DeliveryTime   = model.DeliveryTime.Select(m => new DeliveryTime()
                {
                    Start = m.Start.ToTimeModel(), End = m.End.ToTimeModel()
                }).ToArray(),
                Coordinates = new Coordinates()
                {
                    Longitude = model.Coordinates.Longitude, Latitude = model.Coordinates.Latitude
                }
            };

            return(supplier);
        }
Exemplo n.º 6
0
 /// <summary>
 /// 获取餐厅信息
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public IReturn GetById(int id)
 {
     M.Supplier supplier = M.RepositoryRegistry.Supplier.FindBy(id);
     return(this.Write("GetById", supplier));
 }