public static long Obligation(VM_Obligation obligation) { using (var exodusDB = new exodusEntities()) { var obligationID = new ObjectParameter("obligationID", 0); exodusDB.stp_ObligationAdd( obligationKindID: (long)obligation.ObligationKind.ObligationKindID, currencyID: (int)obligation.ObligationCurrency, amountPerPayment: obligation.AmountPerPayment, amountDue: obligation.AmountDue, amountTotal: obligation.AmountTotal, isActive: obligation.IsActive, obligationPeriodID: (int)obligation.ObligationPeriod, obligationDate: obligation.ObligationDate, obligationExpiration: obligation.ObligationExpiration, obligationClassID: (long)obligation.ObligationClass.ObligationClass, obligationStatusID: (int)obligation.ObligationStatus.ObligationStatus, obligationTypeID: (int)obligation.ObligationType.ObligationTypeID, tagID: obligation.ObligationTag.TagID, applicationID: (int)obligation.ObligationApplication.ApplicationID, issuerUserID: obligation.ObligationIssuer.UserID, holderUserID: obligation.ObligationHolder.UserID, obligationID: obligationID, intentionID: obligation.IntentionID ); return(Convert.ToInt64(obligationID.Value)); } }
public ActionResult Update(FormCollection fc) { VM_Obligation obligation = new VM_Obligation() { IntentionID = Convert.ToInt64(fc["IntentionID"]), // TODO ObligationKind = new VM_ObligationKind { ObligationKindID = (EN_ObligationKind)Convert.ToInt64(fc["ObligationKindID"]) }, ObligationCurrency = (En_Currency)Convert.ToInt32(fc["CurrencyID"]), AmountPerPayment = Convert.ToDecimal(fc["AmountPerPayment"]), AmountDue = Convert.ToDecimal(fc["AmountDue"]), AmountTotal = Convert.ToDecimal(fc["AmountTotal"]), IsActive = Convert.ToBoolean(fc["IsActive"]), ObligationPeriod = (EN_Period)Convert.ToInt32(fc["ObligationPeriodID"]), ObligationDate = DateTime.Parse(fc["ObligationDate"]), ObligationExpiration = DateTime.Parse(fc["ObligationExpiration"]), ObligationClass = new VM_ObligationClass() { ObligationClass = (EN_ObligationClass)Convert.ToInt32(fc["ObligationClass"]) }, ObligationStatus = new VM_ObligationStatus() { ObligationStatus = (EN_ObligationStatus)Convert.ToInt32(fc["ObligationStatus"]) }, ObligationType = new VM_ObligationType() { ObligationTypeID = (EN_ObligationType)Convert.ToInt32(fc["ObligationType"]) } }; // var rez = _DL.Obligation.Update.Obligation(obligation); return(Json(0)); }
public ActionResult Add(FormCollection fc) { VM_Obligation obligation = new VM_Obligation() { IntentionID = Convert.ToInt64(fc["IntentionID"]), // TODO ObligationKind = new VM_ObligationKind { ObligationKindID = (EN_ObligationKind)Convert.ToInt64(fc["ObligationKindID"]) }, ObligationCurrency = (En_Currency)Convert.ToInt32(fc["CurrencyID"]), AmountPerPayment = Convert.ToDecimal(fc["AmountPerPayment"]), AmountDue = Convert.ToDecimal(fc["AmountDue"]), AmountTotal = Convert.ToDecimal(fc["AmountTotal"]), IsActive = Convert.ToBoolean(fc["IsActive"]), ObligationPeriod = (EN_Period)Convert.ToInt32(fc["ObligationPeriodID"]), ObligationDate = DateTime.Parse(fc["ObligationDate"]), ObligationExpiration = DateTime.Parse(fc["ObligationExpiration"]), ObligationClass = new VM_ObligationClass() { ObligationClass = (EN_ObligationClass)Convert.ToInt32(fc["ObligationClass"]) }, ObligationStatus = new VM_ObligationStatus() { ObligationStatus = (EN_ObligationStatus)Convert.ToInt32(fc["ObligationStatus"]) }, ObligationType = new VM_ObligationType() { ObligationTypeID = (EN_ObligationType)Convert.ToInt32(fc["ObligationType"]) }, ObligationApplication = new VM_Application() { ApplicationID = int.Parse(fc["ApplicationID"]) }, ObligationTag = new VM_Tag() { TagID = long.Parse(fc["TagID"]) }, ObligationIssuer = new VM_User() { UserID = long.Parse(fc["IssueUserID"]) }, ObligationHolder = new VM_User() { UserID = long.Parse(fc["HolderUserGuid"]) } }; var rez = _DL.Obligation.Add.Obligation(obligation); return(GetJson(rez)); }
private static VM_Obligation GetFromDB <T>(T obligation) { stp_Obligation_ByID_Result rez = AutoMapper.Mapper.Map <stp_Obligation_ByID_Result>(obligation); VM_Obligation obligationOut = new VM_Obligation() { IntentionID = rez.IntentionID.HasValue ? rez.IntentionID.Value : 0, AmountDue = rez.AmountDue, AmountPerPayment = rez.AmountPerPayment, AmountTotal = rez.AmountTotal, IsActive = rez.IsActive, ObligationApplication = new VM_Application() { ApplicationID = rez.ApplicationID.HasValue ? rez.ApplicationID.Value : 0, ApplicationDescription = rez.ApplicationDescription, ApplicationIsActive = rez.ApplicationIsActive.HasValue ? rez.ApplicationIsActive.Value : false, ApplicationNameEng = rez.ApplicationNameEng, ApplicationNameRus = rez.ApplicationNameRus }, ObligationClass = new VM_ObligationClass() { ObligationClass = (EN_ObligationClass)rez.ObligationClassID, ObligationClassComment = rez.ObligationClassComment, ObligationClassNameEng = rez.ObligationClassNameEng, ObligationClassNameRus = rez.ObligationClassNameRus }, ObligationCurrency = (En_Currency)rez.CurrencyID, ObligationDate = rez.ObligationDate, ObligationExpiration = rez.ObligationExpiration.HasValue ? rez.ObligationExpiration.Value : new DateTime(0), ObligationHolder = new VM_User() { UserID = rez.HolderUserID, UserFirstName = rez.HolderUserFirstName, UserLastName = rez.HolderUserLastName, Avatar = Global.Cache.dicUserAvatars[rez.HolderUserID] }, ObligationID = rez.ObligationID, ObligationIssuer = new VM_User() { UserID = rez.IssuerUserID, UserFirstName = rez.IssuerUserFirstName, UserLastName = rez.IssuerUserLastName, Avatar = Global.Cache.dicUserAvatars[rez.IssuerUserID] }, ObligationKind = new VM_ObligationKind() { ObligationComment = rez.ObligationComment, ObligationKindID = (EN_ObligationKind)rez.ObligationKindID, ObligationNameEng = rez.ObligationNameEng, ObligationNameRus = rez.ObligationNameRus }, ObligationPeriod = (EN_Period)rez.PeriodID, ObligationStatus = new VM_ObligationStatus() { ObligationStatus = (EN_ObligationStatus)rez.ObligationStatusID, ObligationStatusComment = rez.ObligationStatusComment, ObligationStatusNameEng = rez.ObligationStatusNameEng, ObligationStatusNameRus = rez.ObligationStatusNameRus }, ObligationTag = new VM_Tag() { TagID = rez.TagID.HasValue ? rez.TagID.Value : 0, NameEng = rez.TagNameEng, NameRus = rez.TagNameRus, Description = rez.TagDescription }, ObligationType = new VM_ObligationType() { ObligationTypeComment = rez.ObligationTypeComment, ObligationTypeID = (EN_ObligationType)rez.ObligationTypeID, ObligationTypeNameEng = rez.ObligationTypeNameEng, ObligationTypeNameRus = rez.ObligationTypeNameRus } }; return(obligationOut); }