/// <summary> /// Insert new Account item. /// </summary> /// <param name="model">The Account information value.</param> /// <returns></returns> public ResultViewModel Save(AccountViewModel model) { var result = new ResultViewModel(); int id = 0; using (TransactionScope scope = new TransactionScope()) { var account = _mapper.Map <AccountViewModel, Data.Pocos.Account>(model); _unitOfWork.GetRepository <Data.Pocos.Account>().Add(account); _unitOfWork.Complete(scope); id = account.Id; } this.ReloadCacheAccount(); _activityTimeLine.Save(new ActivityTimeLineViewModel { AccountId = id, ActivityComment = ConstantValue.ActCreateAccount }); return(result); }
/// <summary> /// Insert new Contract item. /// </summary> /// <param name="model">The Contract information value.</param> /// <returns></returns> public ResultViewModel Save(ContractViewModel model, string status) { var result = new ResultViewModel(); using (TransactionScope scope = new TransactionScope()) { var contract = _mapper.Map <ContractViewModel, Data.Pocos.Contract>(model); contract.StartDate = UtilityService.ConvertToDateTime(model.StartDateString, ConstantValue.DateTimeFormat); contract.EndDate = UtilityService.ConvertToDateTime(model.EndDateString, ConstantValue.DateTimeFormat); contract.Status = status; _unitOfWork.GetRepository <Data.Pocos.Contract>().Add(contract); _unitOfWork.Complete(); this.SaveItem(contract.Id, model.ContractItems); _unitOfWork.Complete(scope); } _activityTimeLine.Save(new ActivityTimeLineViewModel { AccountId = model.AccountId.Value, ActivityComment = ConstantValue.ActCreateContract }); return(result); }
/// <summary> /// Insert new order item. /// </summary> /// <param name="model">The order information value.</param> /// <returns></returns> public ResultViewModel Save(OrderViewModel model) { var result = new ResultViewModel(); using (TransactionScope scope = new TransactionScope()) { var order = _mapper.Map <OrderViewModel, Data.Pocos.Order>(model); order.EmpId = _token.EmpId; order.OrderDate = DateTime.Now; _unitOfWork.GetRepository <Data.Pocos.Order>().Add(order); _unitOfWork.Complete(); this.SaveItem(order.Id, model.OrderItems); _unitOfWork.Complete(scope); } _activityTimeLine.Save(new Account.Bll.Models.ActivityTimeLineViewModel { AccountId = model.AccountId, ActivityComment = ConstantValue.ActCreateOrder }); return(result); }
public IActionResult Save([FromBody] ActivityTimeLineViewModel model) { return(Ok(_activityTimeline.Save(model))); }