コード例 #1
0
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool Edit(V_xy_sp_spiritequipment model)
        {
            if (model == null)
            {
                return(false);
            }
            using (xy_sp_spiritequipmentDAL dal = new xy_sp_spiritequipmentDAL())
            {
                xy_sp_spiritequipment entitys = ModelToEntity(model);

                return(dal.Edit(entitys));
            }
        }
コード例 #2
0
        public IHttpActionResult Post([FromBody] Request <V_xy_sp_spiritequipment> request)
        {
            V_xy_sp_spiritequipment model = request.Data as V_xy_sp_spiritequipment;

            if (string.IsNullOrEmpty(model.SpiritEquipment))
            {
                bll.Add(model);
            }
            else
            {
                bll.Edit(model);
            }

            return(Ok("ok"));
        }
コード例 #3
0
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public string Add(V_xy_sp_spiritequipment model)
        {
            if (model == null)
            {
                return(string.Empty);
            }

            using (xy_sp_spiritequipmentDAL dal = new xy_sp_spiritequipmentDAL())
            {
                xy_sp_spiritequipment entity = ModelToEntity(model);
                entity.SpiritEquipment = string.IsNullOrEmpty(model.SpiritEquipment) ? Guid.NewGuid().ToString("N") : model.SpiritEquipment;

                return(dal.Add(entity));
            }
        }
コード例 #4
0
        /// <summary>
        /// Model转Entity
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        private xy_sp_spiritequipment ModelToEntity(V_xy_sp_spiritequipment model)
        {
            if (model != null)
            {
                xy_sp_spiritequipment entity = new xy_sp_spiritequipment()
                {
                    SpiritEquipment = model.SpiritEquipment,
                    SpiritID        = model.SpiritID,
                    EquipmentID     = model.EquipmentID,
                    LostRate        = model.LostRate
                };

                return(entity);
            }
            return(null);
        }
コード例 #5
0
        /// <summary>
        /// Entity转Model
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        private V_xy_sp_spiritequipment EntityToModel(xy_sp_spiritequipment entity)
        {
            if (entity != null)
            {
                xy_sp_equipmentBLL      bll   = new xy_sp_equipmentBLL();
                V_xy_sp_spiritequipment model = new V_xy_sp_spiritequipment()
                {
                    SpiritEquipment = entity.SpiritEquipment,
                    SpiritID        = entity.SpiritID,
                    EquipmentID     = entity.EquipmentID,
                    LostRate        = entity.LostRate,
                    equipment       = bll.Get(c => c.EquipmentID == entity.EquipmentID)
                };
                return(model);
            }

            return(null);
        }
コード例 #6
0
        public IHttpActionResult Get(string ID)
        {
            V_xy_sp_spiritequipment model = bll.Get(p => p.SpiritEquipment == ID);

            return(Ok(model));
        }