Ejemplo n.º 1
0
        public ActionResult Save(SeminarRegistration data)
        {
            PureJson result = new PureJson();
            if (string.IsNullOrEmpty(data.firstName))
            {
                using (SPJsonObject jRoot = new SPJsonObject(new JsonKeyValueWriter(result.StringBuilder)))
                {
                    jRoot.Add("Status", 1);
                }
                return new SimpleJsonResult(result);
            }
            else if (string.IsNullOrEmpty(data.lastName))
            {
                using (SPJsonObject jRoot = new SPJsonObject(new JsonKeyValueWriter(result.StringBuilder)))
                {
                    jRoot.Add("Status", 2);
                }
                return new SimpleJsonResult(result);
            }
            else if (string.IsNullOrEmpty(data.userOIB))
            {
                using (SPJsonObject jRoot = new SPJsonObject(new JsonKeyValueWriter(result.StringBuilder)))
                {
                    jRoot.Add("Status", 3);
                }
                return new SimpleJsonResult(result);
            }
            Database.SeminarRegistrationSave(data);

            using (SPJsonObject jRoot = new SPJsonObject(new JsonKeyValueWriter(result.StringBuilder)))
            {
                jRoot.Add("Status", 0);
            }
            return new SimpleJsonResult(result);
        }
Ejemplo n.º 2
0
        public ActionResult Details(string oib)
        {
            if (string.IsNullOrEmpty(oib)) oib = null;
            DataTable table =Database.SeminarList(oib);
            PureJson result = new PureJson();
            if (table.Rows.Count == 0)
            {
                return new SimpleJsonResult();
            }

            using (SPJsonObject jRoot = new SPJsonObject(new JsonKeyValueWriter(result.StringBuilder)))
            {
                jRoot.Add("Status", 0);
                using (SPJsonObject jO = new SPJsonObject(jRoot.GetWriter, "Data"))
                {
                    DataRow last = table.Rows[table.Rows.Count - 1];
                    foreach (DataColumn column in table.Columns)
                    {
                        if (column.ColumnName == "dateOfBirth" && !Utils.IsNull(last[column.ColumnName]))
                        {
                            DateTime born = (DateTime)last[column.ColumnName];
                            jRoot.Add(column.ColumnName, born.ToString("yyyy-MM-dd"));
                        }
                        else
                        {
                            jRoot.Add(column.ColumnName, last[column.ColumnName]);
                        }
                    }
                }

            }

            return new SimpleJsonResult(result);
        }
Ejemplo n.º 3
0
        public ActionResult Load(int UpitnikId)
        {
            DataTable table = Database.HuogUpitnikList(MySession.CurrentUser.Id, UpitnikId);
            PureJson result = new PureJson();
            if (table.Rows.Count != 1)
            {
                return new SimpleJsonResult();
            }

            using (SPJsonObject jRoot = new SPJsonObject(new JsonKeyValueWriter(result.StringBuilder)))
            {
                jRoot.Add("Status", 0);
                jRoot.Add("Id", table.Rows[0]["Id"]);
                jRoot.Add("Naziv", table.Rows[0]["Naziv"]);
                jRoot.Add("Opis", table.Rows[0]["Opis"]);
                jRoot.Add("Datum", table.Rows[0]["Datum"]);

                table = Database.HuogUpitnikVrijednostiList(UpitnikId, null);
                using (SPJsonArray jA = new SPJsonArray(jRoot.GetWriter, "Vrijednosti"))
                {
                    foreach (DataRow row in table.Rows)
                    {
                        for (int i = 1; i <= 10; i++)
                        {
                            if (!Utils.IsNull(row["Vrijednost" + i]))
                            {
                                using (SPJsonObject jO = new SPJsonObject(jA.GetWriter))
                                {
                                    jO.Add("A", i);
                                    jO.Add("P", row["PitanjeId"]);
                                    jO.Add("O", row["Oznaka"]);
                                    jO.Add("V", row["Vrijednost" + i]);
                                }
                            }
                        }
                    }
                }

            }

            return new SimpleJsonResult(result);
        }
Ejemplo n.º 4
0
 public ActionResult SaveUser(LoggedUser model)
 {
     PureJson result = new PureJson();
     model.Id = MySession.CurrentUser.Id;
     LoggedUser user = Database.UserChange(model);
     if (user != null)
     {
         MySession.CurrentUser = user;
         using (SPJsonObject jRoot = new SPJsonObject(new JsonKeyValueWriter(result.StringBuilder)))
         {
             jRoot.Add("Status", 0);
         }
         return new SimpleJsonResult(result);
     }
     using (SPJsonObject jRoot = new SPJsonObject(new JsonKeyValueWriter(result.StringBuilder)))
     {
         jRoot.Add("Status", 1);
     }
     return new SimpleJsonResult(result);
 }
Ejemplo n.º 5
0
 public ActionResult Register(LoggedUser model)
 {
     PureJson result = new PureJson();
     if (ModelState.IsValid)
     {
         LoggedUser user = Database.Login(model.Email, model.Password);
         if (user != null)
         {
             using (SPJsonObject jRoot = new SPJsonObject(new JsonKeyValueWriter(result.StringBuilder)))
             {
                 jRoot.Add("Status", 2);
             }
             return new SimpleJsonResult(result);
         }
         user = Database.Register(model);
         if (user != null)
         {
             int r = SendRegistrationMail(model);
             //FormsAuthentication.SetAuthCookie(model.Email, false);
             //MySession.CurrentUser = user;
             using (SPJsonObject jRoot = new SPJsonObject(new JsonKeyValueWriter(result.StringBuilder)))
             {
                 jRoot.Add("Status", 0);
             }
             return new SimpleJsonResult(result);
         }
     }
     using (SPJsonObject jRoot = new SPJsonObject(new JsonKeyValueWriter(result.StringBuilder)))
     {
         jRoot.Add("Status", 1);
     }
     return new SimpleJsonResult(result);
 }
Ejemplo n.º 6
0
 public ActionResult LogOn(LogOnModel model, string returnUrl)
 {
     PureJson result = new PureJson();
     if (ModelState.IsValid)
     {
         LoggedUser user = Database.Login(model.Email, model.Password);
         if (user != null && user.Status > 1)
         {
             MySession.CurrentUser = user;
             FormsAuthentication.SetAuthCookie(model.Email, model.RememberMe);
             using (SPJsonObject jRoot = new SPJsonObject(new JsonKeyValueWriter(result.StringBuilder)))
             {
                 jRoot.Add("Status", 0);
             }
             return new SimpleJsonResult(result);
         }
         else if (user != null && user.Status <= 1)
         {
             using (SPJsonObject jRoot = new SPJsonObject(new JsonKeyValueWriter(result.StringBuilder)))
             {
                 jRoot.Add("Status", 2);
             }
             return new SimpleJsonResult(result);
         }
     }
     using (SPJsonObject jRoot = new SPJsonObject(new JsonKeyValueWriter(result.StringBuilder)))
     {
         jRoot.Add("Status", 1);
     }
     return new SimpleJsonResult(result);
 }
Ejemplo n.º 7
0
 public ActionResult SeminarDetails(int id)
 {
     PureJson result = new PureJson();
     DataTable data = Database.HuogTecajList(DateTime.Today);
     DataRow current = null;
     foreach (DataRow row in data.Rows)
     {
         if ((int)row["Id"] == id)
             current = row;
     }
     if (current != null)
     {
         using (SPJsonObject jRoot = new SPJsonObject(new JsonKeyValueWriter(result.StringBuilder)))
         {
             jRoot.Add("Status", 0);
             using (SPJsonObject jO = new SPJsonObject(jRoot.GetWriter, "Data"))
             {
                 jO.Add("SeminarId", current["Id"]);
                 jO.Add("Title", current["Title"]);
                 jRoot.Add("DateFrom", Utils.ToISODateString(current["DateFrom"]));
                 jRoot.Add("DateTo", Utils.ToISODateString(current["DateTo"]));
                 jO.Add("Active", current["Active"]);
                 jO.Add("Description", current["Description"]);
             }
         }
         return new SimpleJsonResult(result);
     }
     else
     {
         return new SimpleJsonResult();
     }
 }
Ejemplo n.º 8
0
 public ActionResult SeminarUserList(int? SeminarId, string DateFrom, string DateTo)
 {
     PureJson result = new PureJson();
     DataTable table = Database.SeminarRegistrationSearch(SeminarId, DateFrom, DateTo);
     using (SPJsonObject jRoot = new SPJsonObject(new JsonKeyValueWriter(result.StringBuilder)))
     {
         jRoot.Add("Status", 0);
         using (SPJsonArray jA = new SPJsonArray(jRoot.GetWriter, "List"))
         {
             foreach (DataRow row in table.Rows)
             {
                 using (SPJsonObject jO =new SPJsonObject(jRoot.GetWriter))
                 {
                     foreach (DataColumn column in table.Columns)
                     {
                         if (column.ColumnName == "dateOfBirth" && !Utils.IsNull(row[column.ColumnName]))
                         {
                             DateTime born = (DateTime)row[column.ColumnName];
                             jRoot.Add(column.ColumnName, Utils.ToISODateString(born));
                         }
                         else if (column.ColumnName == "dateCreated" && !Utils.IsNull(row[column.ColumnName]))
                         {
                             DateTime dt = (DateTime)row[column.ColumnName];
                             jRoot.Add(column.ColumnName, Utils.ToISODateString(dt));
                         }
                         else
                         {
                             jRoot.Add(column.ColumnName, row[column.ColumnName]);
                         }
                     }
                 }
             }
         }
     }
     return new SimpleJsonResult(result);
 }
Ejemplo n.º 9
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);
 }