Пример #1
0
 public static FeePayable ToModel(this fees_type row)
 {
     return(new FeePayable()
     {
         id = row.id.ToString(),
         name = row.name,
         school_name = row.school.name,
         amount = row.amount.ToString("n2")
     });
 }
Пример #2
0
        public ActionResult Save(int?id, int schoolid, string name, string amount)
        {
            if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(amount))
            {
                return(Json("Name and amount must be specified".ToJsonFail()));
            }

            var feetype = new fees_type();

            if (id.HasValue)
            {
                feetype = db.fees_types.Single(x => x.id == id.Value);
            }
            feetype.name     = name;
            feetype.schoolid = schoolid;
            feetype.amount   = decimal.Parse(amount, NumberStyles.AllowDecimalPoint | NumberStyles.AllowThousands);

            if (!id.HasValue)
            {
                db.fees_types.InsertOnSubmit(feetype);
            }
            try
            {
                repository.Save();
            }
            catch (Exception ex)
            {
                Syslog.Write(ex);
            }

            var view = this.RenderViewToString("FeesContent", new[] { feetype.ToModel() });

            var viewmodel = "Entry saved successfully".ToJsonOKMessage();

            viewmodel.data = view;
            return(Json(viewmodel));
        }