public async Task <ActionResult <Label> > PostLabel(Label label) { if (_labelService.Add(label)) { // Label was added successfully return(CreatedAtAction(nameof(GetLabel), new { id = label.Id }, label)); } // Something went wrong internally with adding the TodoItem return(StatusCode(StatusCodes.Status500InternalServerError)); }
private void Fill() { var unitOfWork = GetAppService <IUnitOfWork>(); unitOfWork.BeginTransaction(); var labels = new List <Label>(); var payments = new List <Payment>(); ILabelService labelService = GetAppService <ILabelService>(); for (int i = 0; i < NUMBER_OBJ; i++) { labels.Add(labelService.Add(new Label { Name = string.Format(Resource.LabelName, i + 1) })); } IPaymentService paymentService = GetAppService <IPaymentService>(); for (int i = 0; i < NUMBER_OBJ; i++) { payments.Add(paymentService.Add(new Payment { Name = string.Format(Resource.PaymentName, i + 1) })); } IExpenseService expenseService = GetAppService <IExpenseService>(); for (int i = 0; i < NUMBER_OBJ; i++) { expenseService.Add(new Expense { Name = string.Format(Resource.PaymentName, i + 1), Data = DateTime.Today, Value = i + 1, Label = labels[i], LabelId = labels[i].Id, Payment = payments[i], PaymentId = payments[i].Id, IsIncoming = i % 2 == 0 }); } unitOfWork.Commit(); }
public virtual ActionResult Add(AddLabelModel labelModel) { if (_labelService.IsExist(labelModel.Name)) { return(PartialView(MVC.Admin.Shared.Views._Alert, new Alert { Message = "برچسبی با این نام موجود می باشد", Mode = AlertMode.Error })); } _labelService.Add(new Label { Name = labelModel.Name, Description = labelModel.Description }); _uow.SaveChanges(); return(PartialView(MVC.Admin.Shared.Views._Alert, new Alert { Message = "برچسب جدید با موفقیت در سیستم ثبت شد", Mode = AlertMode.Success })); }