Esempio n. 1
0
        public int? SeminarSave(Seminar input)
        {
            string com = input.SeminarId.HasValue ? "tblHuogTecaj_update" : "tblHuogTecaj_insert";
            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew))
            {
                using (DbCommand command = GetCommand(com))
                {
                    SetParameterValue(command, "@Title", input.Title);
                    SetParameterValue(command, "@DateFrom", input.DateFrom);
                    SetParameterValue(command, "@DateTo", input.DateTo);
                    SetParameterValue(command, "@Active", input.Active);
                    SetParameterValue(command, "@Description", input.Description);
                    if (input.SeminarId.HasValue)
                    {
                        SetParameterValue(command, "@Id", input.SeminarId.Value);
                    }
                    else
                    {
                        GetParameter(command, "@Id").Direction = ParameterDirection.Output;
                    }

                    ExecuteNonQuery(command);

                    if (!input.SeminarId.HasValue)
                    {
                        input.SeminarId = (int)GetParameterValue(command, "Id");
                    }

                }
                scope.Complete();
            }
            return input.SeminarId;
        }
Esempio n. 2
0
 public ActionResult SeminarSave(Seminar input)
 {
     PureJson result = new PureJson();
     Database.SeminarSave(input);
     using (SPJsonObject jRoot = new SPJsonObject(new JsonKeyValueWriter(result.StringBuilder)))
     {
         jRoot.Add("Status", 0);
         using (SPJsonObject jO = new SPJsonObject(jRoot.GetWriter, "Data"))
         {
             jO.Add("SeminarId", input.SeminarId);
             jO.Add("Title", input.Title);
             jRoot.Add("DateFrom", input.DateFrom);
             jRoot.Add("DateTo", input.DateTo);
             jO.Add("Active", input.Active);
             jO.Add("Description", input.Description);
         }
     }
     return new SimpleJsonResult(result);
 }