Example #1
0
        public async Task <IHttpActionResult> PostCM_Account(CM_Account cM_Account)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.CM_Account.Add(cM_Account);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (CM_AccountExists(cM_Account.Id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = cM_Account.Id }, cM_Account));
        }
Example #2
0
        public async Task <IHttpActionResult> PutCM_Account(Guid id, CM_Account cM_Account)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != cM_Account.Id)
            {
                return(BadRequest());
            }

            db.Entry(cM_Account).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CM_AccountExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #3
0
        public async Task <IHttpActionResult> GetCM_Account(Guid id)
        {
            CM_Account cM_Account = await db.CM_Account.FindAsync(id);

            if (cM_Account == null)
            {
                return(NotFound());
            }

            return(Ok(cM_Account));
        }
Example #4
0
        public async Task <IHttpActionResult> DeleteCM_Account(Guid id)
        {
            CM_Account cM_Account = await db.CM_Account.FindAsync(id);

            if (cM_Account == null)
            {
                return(NotFound());
            }

            db.CM_Account.Remove(cM_Account);
            await db.SaveChangesAsync();

            return(Ok(cM_Account));
        }
Example #5
0
        public string AddTest()
        {
            CM_Account dataEntity = new CM_Account();

            dataEntity.AccountCode = "asdfsd";
            dataEntity.CreateTime  = DateTime.Now;

            AddAccountCommand cmd = new AddAccountCommand(dataEntity);

            CommandBus.Send <AddAccountCommand>(cmd);
            if (cmd.SimpleResult != null)
            {
                //  BusinessID = DataTypeConvert.ToInt32(cmd.SimpleResult.Message);
            }
            return("");
        }
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="dataEntity">数据实体</param>
 public AddAccountCommand(CM_Account dataEntity)
 {
     this.MCM_Account = dataEntity;
 }