Exemplo n.º 1
0
        public HomeController(TDRContext context, ISafaricomFormService safaricomFormService,IUserRepository userRepository)
        {
            _context = context;
            _safaricomFormService = safaricomFormService;
            _userRepository = userRepository;
            if(!_context.Users.Any(s=>s.Username.ToLower()=="admin"))
            {
                var user1 = new User
                                {

                                    CreatedOn = DateTime.Now,
                                    Email = "",
                                    Fullname = "admin",
                                    Id = Guid.NewGuid(),
                                    IsActive = false,
                                    Password = Md5Hash.GetMd5Hash("1234"),
                                    PhoneNumber = "00000000",
                                    UserType = UserType.Admin,
                                    UpdatedOn = DateTime.Now,

                                    Username = "******"

                                };
                _context.Users.Add(user1);
                _context.SaveChanges();
            }
        }
Exemplo n.º 2
0
        public ActionResult seed()
        {
            TDRContext context = new TDRContext();
            if(context.Forms.Any(s=>s.Name=="Safaricom"))
            {
                return View();
            }
            //var formid = CreateForm("Safaricom");
            //var formRespondentid1 = CreateFormRespondentType(formid,"Dealer","D");
            //var formRespondentid2 = CreateFormRespondentType(formid, "M-Pesa", "M");
            //var formitem1 = CreateFormItem(formid,"What is your name ?",DformItemType.Text,1,true);
            //CreateItemRespondentType(formitem1,formRespondentid1);
            //CreateItemRespondentType(formitem1, formRespondentid2);

            //var formitem2 = CreateFormItem(formid, "What is your Gender?", DformItemType.DropdownList, 2, true);
            //CreateItemRespondentType(formitem2, formRespondentid1);
            //CreateItemRespondentType(formitem2, formRespondentid2);
            //CreateAnswers(formitem2, "MALE", "M");
            //CreateAnswers(formitem2, "FEMALE", "F");

            //var formitem3 = CreateFormItem(formid, "Which of the following Product do you use?", DformItemType.MultiChoice, 3, true);
            //CreateItemRespondentType(formitem3, formRespondentid1);
            //CreateItemRespondentType(formitem3, formRespondentid2);
            //CreateAnswers(formitem3, "BANANA", "B");
            //CreateAnswers(formitem3, "MANGO", "M");
            //CreateAnswers(formitem3, "ORANGE", "O");
            //CreateAnswers(formitem3, "APLE", "A");

            return View();
        }
Exemplo n.º 3
0
        public string Index()
        {
            List<ActiveOutlet> list = new List<ActiveOutlet>();
            TDRContext db = new TDRContext();
            var statuses = new List<string> {"Active", "Closed", "Suspended", "Relocated", "MIT"};
            foreach (var resp in db.FormRespondentTypes.Where(s => s.Form.IdCode == "SAF_D_D_F" & s.Name == "M-PESA").ToList())
            {
                foreach (var status in statuses)
                {
                    var active = new ActiveOutlet();
                    active.RespondentType = resp.Name;
                    active.Status = status;
                    active.Count = db.FormResultItem.Count(s => s.FormItem.Order == 4 && s.FormItemAnswer == status && s.FormResult.RespondentTypeId==resp.Id);
                    list.Add(active);
                }

            }
             var data=list.ToList().ToDataTable();
             var data2 = PivotHelper.Pivot(data, "RespondentType", "Status", "Count");
             return new GoogleDataTable(data2).GetJson();
        }
Exemplo n.º 4
0
 public FormRepository(TDRContext context)
 {
     _context = context;
 }
Exemplo n.º 5
0
 public ClientRepository(TDRContext context)
 {
     _context = context;
 }
Exemplo n.º 6
0
 public LocationRepository(TDRContext context)
 {
     _context = context;
 }
Exemplo n.º 7
0
 public SafaricomFormService(TDRContext context)
     : base(context)
 {
 }
Exemplo n.º 8
0
 public ReportGroupRepository(TDRContext context)
 {
     _context = context;
 }
Exemplo n.º 9
0
 public ConfigRepository(TDRContext context)
 {
     _context = context;
 }
Exemplo n.º 10
0
 public FormController(TDRContext context, IFormService formService)
 {
     _context = context;
     _formService = formService;
 }
Exemplo n.º 11
0
 public UserRepository(TDRContext context)
 {
     _context = context;
 }
Exemplo n.º 12
0
 public FormServiceBase(TDRContext context)
 {
     _context = context;
 }