public FantomModel CreateFantom(CreateFantomModel item, UserModel user) { if (item == null) { throw new ArgumentNullException("Не могу создать запись.\r\nЗапись не была получена"); } if (item.Sum < 0.01m) { throw new NotSupportedException("Сумма должна быть больше 0.01"); } if (String.IsNullOrWhiteSpace(item.SupplierName)) { throw new NotSupportedException("Поставщик не был получен"); } item.SupplierName = item.SupplierName.ToStringTrim(); item.Comment = item.Comment.ToStringTrim(); if (!String.IsNullOrWhiteSpace(item.Comment) && item.Comment.Length > 100) { throw new NotSupportedException("Длина комментария не должна превышать 100 символов"); } CheckDate(item.PeriodDate); var newitem = new FantomModel(item); Util.DoActionTransaction <T>(p => { var dbitem = new Pay { UID = newitem.UID, EventDate = newitem.EventDate }; dbitem.Supplier = AddNewSupplier(item.SupplierName, p).UID; dbitem.Commеnt = item.Comment; dbitem.Currency = (int)item.Currency; dbitem.EventDate = DateTime.Now; dbitem.PeriodDate = item.PeriodDate; dbitem.Action = (int)item.TypeAccount; dbitem.Sum = item.Sum; dbitem.UserID = user.ID; p.Pays.AddObject(dbitem); }); return(newitem); }
FantomModel IFantomService.CreateFantom(ApplicationVersion applicationVersion, CreateFantomModel item) { return(RunSecurity(applicationVersion, (user) => { CheckRightsFantom(user); return _RepositoryFantom.CreateFantom(item, user); })); }