public Auxiliary SaveAuxiliary(AuxiliaryViewModel vmAux) { Auxiliary aux = new Auxiliary(); if (vmAux.AuxId > 0) { aux = _ledger.Auxiliarys.Where(a => a.AuxId == vmAux.AuxId).FirstOrDefault(); if (aux == null) { return(null); } aux.AuxName = vmAux.AuxName; } else { aux.AuxCode = vmAux.AuxCode; aux.AuxName = vmAux.AuxName; aux.AuxiliaryState = AuxiliaryState.Normal; aux.AuxiliaryType = _ledger.AuxiliaryType.Where(at => at.AtId == vmAux.AtId).FirstOrDefault(); aux.AccountBook = _acctBook.GetAccountBook(_cache.GetUserCache().AccountBookID); aux.Creator = _context.User.Identity.Name; aux.CreateTime = DateTime.Now; _ledger.Auxiliarys.Add(aux); } if (_ledger.SaveChanges() > 0) { return(aux); } return(null); }
public IHttpActionResult SaveAuxiliary(AuxiliaryViewModel vmAux) { _auxType.SaveAuxiliary(vmAux); return(Ok(ResMessage.Success())); }