Exemplo n.º 1
0
        public List <Category> GetCategoryList(string userid)
        {
            List <Category> catListModel = new List <Category>();

            if (userid != null)
            {
                using (var db = new Expense_ManagerEntities())
                {
                    int             id         = int.Parse(userid);
                    int             count      = db.category.Where(m => m.user_id == id).Count();
                    List <category> catListDAL = new List <category>();
                    catListDAL = db.category.Where(m => m.user_id == id).ToList();
                    foreach (var item in catListDAL)
                    {
                        Category catModel = new Category();
                        catModel.id            = item.id;
                        catModel.category_name = item.category_name;
                        catModel.user_id       = item.user_id;
                        catListModel.Add(catModel);
                    }
                    catListModel.Reverse();  //i am reversing it to display the latest added data on top
                }
            }
            return(catListModel);
        }
Exemplo n.º 2
0
        public bool IsCategoryExist(category Category)
        {
            bool result;

            using (var db = new Expense_ManagerEntities())
            {
                category cat = new category();
                result = db.category.Where(x => x.category_name == Category.category_name && x.user_id == Category.user_id).Any();
            }
            return(result);
        }
Exemplo n.º 3
0
        public int CheckUsernameIsExist(string email)
        {
            int result = 0;

            using (var db = new Expense_ManagerEntities())
            {
                bool isvalid = db.user_info.Any(x => x.email == email);
                if (isvalid)
                {
                    result = 1;
                }
            }
            return(result);
        }
Exemplo n.º 4
0
        public int DeleteCategory(int ctgryId)
        {
            int result = 0;

            if (ctgryId > 0)
            {
                using (var db = new Expense_ManagerEntities())
                {
                    var a = db.category.Find(ctgryId);
                    db.category.Remove(a);
                    db.SaveChanges();
                    result = 1;
                }
            }
            return(result);
        }
Exemplo n.º 5
0
        public int EditCategory(int id, string name)
        {
            int result = 0;

            if (id > 0 && name != null)
            {
                using (var db = new Expense_ManagerEntities())
                {
                    var a = db.category.FirstOrDefault(x => x.id == id);
                    if (a != null)
                    {
                        a.category_name = name;
                        db.SaveChanges();
                        result = 1;
                    }
                }
            }
            return(result);
        }
Exemplo n.º 6
0
        public int AddRecord(Models.Records rec)
        {
            int result = 0;

            using (var db = new Expense_ManagerEntities())
            {
                record recDAL = new record();
                recDAL.userid         = rec.userid;
                recDAL.expense_income = rec.expense_income;
                recDAL.amount         = rec.amount;
                recDAL.category       = rec.category;
                recDAL.date           = rec.date;
                recDAL.notes          = rec.notes;

                db.record.Add(recDAL);
                db.SaveChanges();
                result = 1;
            }
            return(result);
        }
Exemplo n.º 7
0
        public int Register(Models.UserInfo info)
        {
            int result = 0;

            using (var db = new Expense_ManagerEntities())
            {
                user_info DALInfo = new user_info();
                DALInfo.firstname        = info.firstname;
                DALInfo.lastname         = info.lastname;
                DALInfo.email            = info.email;
                DALInfo.password         = info.password;
                DALInfo.confirm_password = info.confirm_password;
                DALInfo.profile_pic_path = info.profile_pic_path;

                db.user_info.Add(DALInfo);
                db.SaveChanges();
                result = 1;
            }
            return(result);
        }
Exemplo n.º 8
0
        public int AddCategory(Models.Category Category)
        {
            int result = 0;

            using (var db = new Expense_ManagerEntities())
            {
                if (Category.category_name != null)
                {
                    category cat = new category();
                    cat.category_name = Category.category_name;
                    cat.user_id       = Category.user_id;
                    if (IsCategoryExist(cat))
                    {
                        return(2);
                    }
                    db.category.Add(cat);
                    db.SaveChanges();
                    result = 1;
                }
            }
            return(result);
        }
Exemplo n.º 9
0
        public Models.UserInfo FetchUserInfo(Models.Login info)
        {
            Models.UserInfo BALinfo = new Models.UserInfo();
            using (var db = new Expense_ManagerEntities())
            {
                bool isvalid = db.user_info.Any(x => x.email == info.email && x.password == info.password);
                if (isvalid)
                {
                    DAL.user_info DALinfo = db.user_info.Where(x => x.email == info.email && x.password == info.password).FirstOrDefault();
                    BALinfo.id               = DALinfo.id;
                    BALinfo.firstname        = DALinfo.firstname;
                    BALinfo.lastname         = DALinfo.lastname;
                    BALinfo.email            = DALinfo.email;
                    BALinfo.password         = DALinfo.password;
                    BALinfo.confirm_password = DALinfo.confirm_password;
                    BALinfo.month_start_date = DALinfo.month_start_date;
                    BALinfo.profile_pic_path = DALinfo.profile_pic_path;

                    //var userdetail2 = from s in db.user_info where s.email == info.email && s.password == info.password select s;
                }
            }
            return(BALinfo);
        }
Exemplo n.º 10
0
        public int IsUserExistWithUsernamePass(Models.Login info)
        {
            int result = 1;

            using (var db = new Expense_ManagerEntities())
            {
                bool isUserexist   = db.user_info.Any(x => x.email == info.email);
                bool isCorrectPass = false;
                if (isUserexist)
                {
                    isCorrectPass = db.user_info.Any(x => x.email == info.email && x.password == info.password);
                    if (!isCorrectPass)
                    {
                        result = -1;
                    }
                }
                else
                {
                    result = -2;
                }
            }
            return(result);
        }