Exemplo n.º 1
0
        public static ResponResultViewModel Is_Delete(MonitoringViewModel entity)
        {
            ResponResultViewModel result = new ResponResultViewModel();

            try
            {
                using (var db = new MinProContext())
                {
                    t_monitoring mn = db.t_monitoring.Where(o => o.id == entity.id).FirstOrDefault();
                    if (mn != null)
                    {
                        mn.is_delete  = true;
                        mn.deleted_by = 1;
                        mn.deleted_on = DateTime.Now;
                        db.SaveChanges();
                        result.Entity = entity;
                    }
                }
            }
            catch (Exception ex)
            {
                result.Success = false;
                result.Message = ex.Message;
            }
            return(result);
        }
Exemplo n.º 2
0
        public static ResponResultViewModel Delete(long id)
        {
            ResponResultViewModel result = new ResponResultViewModel();

            try
            {
                using (var db = new MinProContext())
                {
                    t_bootcamp_type bt = db.t_bootcamp_type.Where(o => o.id == id).FirstOrDefault();
                    if (bt == null)
                    {
                        result.Success = false;
                        result.Message = "Bootcamp Type Not Found";
                    }
                    else
                    {
                        result.Entity = bt;
                        db.t_bootcamp_type.Remove(bt);
                        db.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                result.Success = false;
                result.Message = ex.Message;
            }
            return(result);
        }
Exemplo n.º 3
0
        public static MonitoringViewModel GetMonitoring(long id)
        {
            MonitoringViewModel result = new MonitoringViewModel();

            using (var db = new MinProContext())
            {
                result = (from c in db.t_monitoring
                          join d in db.t_biodata on
                          c.biodata_id equals d.id
                          select new MonitoringViewModel
                {
                    id = c.id,
                    bio_name = d.name,
                    biodata_id = c.biodata_id,
                    idle_date = c.idle_date,
                    last_project = c.last_project,
                    idle_reason = c.idle_reason,
                    placement_date = c.placement_date,
                    placement_at = c.placement_at,
                    notes = c.notes,
                    is_delete = c.is_delete,
                }).FirstOrDefault();
                if (result == null)
                {
                    result = new MonitoringViewModel();
                }
            }
            return(result);
        }
Exemplo n.º 4
0
        public static UserViewModel CheckUser(UserViewModel model)
        {
            UserViewModel result = new UserViewModel();

            //check user ada atau tidak
            using (MinProContext db = new MinProContext())
            {
                result = (from f in db.t_user
                          where f.username == model.username && f.active == true
                          select new UserViewModel
                {
                    id = f.id,
                    username = f.username,
                    password = model.password
                }).FirstOrDefault();
            }
            if (result != null)
            {
                return(result);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 5
0
        public static ResponResultViewModel Deact(TestViewModel model)
        {
            ResponResultViewModel result = new ResponResultViewModel();

            using (var db = new MinProContext())
            {
                t_test test = db.t_test.Where(x => x.id == model.id).FirstOrDefault();
                test.active      = false;
                test.modified_by = 1;
                test.modified_on = DateTime.Now;
                test.name        = model.name;

                try
                {
                    db.SaveChanges();
                    result.Entity = model;
                }
                catch (Exception e)
                {
                    result.Success = false;
                    result.Message = e.Message;
                }
            }
            return(result);
        }
Exemplo n.º 6
0
        public static ResponResultViewModel Update(ClassViewModel entity)
        {
            //untuk create & edit
            ResponResultViewModel result = new ResponResultViewModel();

            try
            {
                using (var db = new MinProContext())
                {
                    t_clazz clazz = new t_clazz();
                    clazz.batch_id   = entity.id;
                    clazz.biodata_id = entity.id;
                    clazz.created_by = 1;
                    clazz.created_on = DateTime.Now;

                    db.t_clazz.Add(clazz);
                    db.SaveChanges();

                    result.Entity = clazz;
                }
            }
            catch (Exception e)
            {
                result.Success = false;
                result.Message = e.Message;
            }
            return(result);
        }
Exemplo n.º 7
0
        public static bool Update2(UserViewModel model)
        {
            bool result = false;

            using (MinProContext db = new MinProContext())
            {
                t_user user = db.t_user.Find(model.id);
                user.username     = model.username;
                user.password     = model.password;
                user.role_id      = model.role_id;
                user.mobile_flag  = model.mobile_flag;
                user.mobile_token = model.mobile_token;
                user.created_by   = model.id;
                user.created_on   = DateTime.Now;
                user.modified_by  = model.id;
                user.modified_on  = DateTime.Now;
                user.active       = model.active;

                try
                {
                    db.SaveChanges();
                    result = true;
                }
                catch (Exception e)
                {
                    result = false;
                }
            }


            return(result);
        }
Exemplo n.º 8
0
        public static ResponResultViewModel Deactive(MenuViewModel entity, long userid)
        {
            //untuk deactive
            ResponResultViewModel result = new ResponResultViewModel();

            try
            {
                using (var db = new MinProContext())
                {
                    t_menu menu = db.t_menu.Where(x => x.id == entity.id).FirstOrDefault();
                    if (menu != null)
                    {
                        menu.active      = false;
                        menu.modified_by = userid;
                        menu.modified_on = DateTime.Now;
                        db.SaveChanges();
                        result.Entity = entity;
                    }
                    else
                    {
                        result.Success = false;
                        result.Message = "user not found!";
                    }
                }
            }
            catch (Exception e)
            {
                result.Success = false;
                result.Message = e.Message;
            }
            return(result);
        }
Exemplo n.º 9
0
        public static ClassViewModel Get(int id)
        {
            ClassViewModel result = new ClassViewModel();

            using (var db = new MinProContext())
            {
                result = (from c in db.t_clazz
                          join b in db.t_batch on c.batch_id equals b.id
                          join s in db.t_biodata on c.biodata_id equals s.id
                          where c.id == id
                          select new ClassViewModel
                {
                    id = c.id,
                    batch_id = c.id,
                    batchname = b.name,
                    biodata_id = c.id,
                    bioname = s.name
                }).FirstOrDefault();

                //if (result == null)
                //{
                //    result = new CategoryViewModel();
                //}
            }
            return(result);
        }
Exemplo n.º 10
0
        public static ResponResultViewModel Update(MenuAccessViewModel entity)
        {
            ResponResultViewModel result = new ResponResultViewModel();

            try
            {
                using (var db = new MinProContext())
                {
                    if (entity.id == 0)
                    {
                        t_menu_access ma = new t_menu_access();
                        ma.menu_id    = entity.menu_id;
                        ma.role_id    = entity.role_id;
                        ma.created_by = 1;
                        ma.created_on = DateTime.Now;

                        db.t_menu_access.Add(ma);
                        db.SaveChanges();
                        result.Entity = entity;
                    }
                }
            }
            catch (Exception ex)
            {
                result.Success = false;
                result.Message = ex.Message;
            }
            return(result);
        }
Exemplo n.º 11
0
        public static ResponResultViewModel Delete(long id)
        {
            ResponResultViewModel result = new ResponResultViewModel();

            try
            {
                using (var db = new MinProContext())
                {
                    t_menu_access ma = db.t_menu_access.Where(o => o.id == id).FirstOrDefault();
                    if (ma == null)
                    {
                        result.Success = false;
                        result.Message = "Menu Access Not Found";
                    }
                    else
                    {
                        result.Entity = ma;
                        db.t_menu_access.Remove(ma);
                        db.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                result.Success = false;
                result.Message = ex.Message;
            }
            return(result);
        }
Exemplo n.º 12
0
        public static AssignmentViewModel GetAssignment(int id)
        {
            AssignmentViewModel result = new AssignmentViewModel();

            using (var db = new MinProContext())
            {
                result = (from c in db.t_assignment
                          join d in db.t_biodata on
                          c.biodata_id equals d.id
                          select new AssignmentViewModel
                {
                    id = c.id,
                    bio_name = d.name,
                    biodata_id = c.biodata_id,
                    title = c.title,
                    start_date = c.start_date,
                    end_date = c.end_date,
                    description = c.description,
                    realization_date = c.realization_date,
                    notes = c.notes,
                    is_hold = c.is_hold,
                    is_done = c.is_done,
                    is_delete = c.is_delete,
                }).FirstOrDefault();
                if (result == null)
                {
                    result = new AssignmentViewModel();
                }
            }
            return(result);
        }
Exemplo n.º 13
0
        public static ResponResultViewModel CreatePlacement(MonitoringViewModel entity)
        {
            //Untuk placement
            ResponResultViewModel result = new ResponResultViewModel();

            try
            {
                using (var db = new MinProContext())

                {
                    t_monitoring mn = db.t_monitoring.Where(o => o.id == entity.id).FirstOrDefault();
                    if (mn != null)
                    {
                        mn.placement_date = entity.placement_date;
                        mn.placement_at   = entity.placement_at;
                        mn.notes          = entity.notes;

                        mn.modified_by = 2;
                        mn.modified_on = DateTime.Now;

                        db.SaveChanges();

                        result.Entity = entity;
                    }
                }
            }
            catch (Exception ex)
            {
                result.Success = false;
                result.Message = ex.Message;
            }
            return(result);
        }
Exemplo n.º 14
0
        public static List <QuestionViewModel> All(string searchString)
        {
            List <QuestionViewModel> result = new List <QuestionViewModel>();

            using (var db = new MinProContext())
            {
                if (String.IsNullOrEmpty(searchString))
                {
                    result = (from c in db.t_question
                              where c.is_delete == false
                              select new QuestionViewModel
                    {
                        id = c.id,
                        question = c.question
                    }).ToList();
                }
                else
                {
                    var hi = from s in db.t_question
                             where s.is_delete == false
                             select new QuestionViewModel
                    {
                        id       = s.id,
                        question = s.question
                    };
                    hi     = hi.Where(s => s.question.Contains(searchString));
                    result = hi.ToList();
                }
            }
            return(result);
        }
Exemplo n.º 15
0
        public static List <TestimonyViewModel> All(string searchString)
        {
            List <TestimonyViewModel> result = new List <TestimonyViewModel>();

            using (var db = new MinProContext())
            {
                if (String.IsNullOrEmpty(searchString))
                {
                    result = (from ts in db.t_testimony
                              where ts.is_delete == false
                              select new TestimonyViewModel
                    {
                        id = ts.id,
                        title = ts.title,
                        content = ts.content,
                        is_delete = ts.is_delete
                    }).ToList();
                }
                else
                {
                    var s = from ts in db.t_testimony
                            where ts.is_delete == false
                            select new TestimonyViewModel
                    {
                        id        = ts.id,
                        title     = ts.title,
                        content   = ts.content,
                        is_delete = ts.is_delete
                    };
                    s      = s.Where(ts => ts.title.Contains(searchString));
                    result = s.ToList();
                }
            }
            return(result);
        }
Exemplo n.º 16
0
        // mengakses item individual dari Room
        public static RoomViewModel GetRoom(int id)
        {
            RoomViewModel result = new RoomViewModel();

            using (var db = new MinProContext())
            {
                result = (from roomItem in db.t_room
                          join officeItem in db.t_office
                          on roomItem.office_id equals officeItem.id
                          where roomItem.id == id
                          select new RoomViewModel
                {
                    id = roomItem.id,
                    code = roomItem.code,
                    name = roomItem.name,
                    capacity = roomItem.capacity,
                    any_projector = roomItem.any_projector,
                    notes = roomItem.notes,
                    office_id = roomItem.office_id,
                    office_name = officeItem.name,
                    active = roomItem.active
                }).FirstOrDefault();
            }

            return(result != null ? result : new RoomViewModel());
        }
Exemplo n.º 17
0
        public static BatchViewModel Get(int id)
        {
            BatchViewModel result = new BatchViewModel();

            using (var db = new MinProContext())
            {
                result = (from b in db.t_batch
                          join t in db.t_technology on b.technology_id equals t.id
                          join r in db.t_trainer on b.trainer_id equals r.id
                          join o in db.t_room on b.room_id equals o.id
                          join y in db.t_bootcamp_type on b.bootcamp_type_id equals y.id
                          where b.id == id && b.is_delete == false
                          select new BatchViewModel
                {
                    id = b.id,
                    technology_id = b.technology_id,
                    techname = t.name,
                    name = b.name,
                    trainer_id = b.trainer_id,
                    trainername = r.name,
                    period_from = b.period_from,
                    period_to = b.period_to,
                    room_id = b.room_id,
                    bootcamp_type_id = b.bootcamp_type_id,
                    notes = b.notes,
                    is_delete = b.is_delete
                }).FirstOrDefault();

                //if (result == null)
                //{
                //    result = new CategoryViewModel();
                //}
            }
            return(result);
        }
Exemplo n.º 18
0
        // mengakses semua RoomViewModel dan dijadikan List
        public static List <RoomViewModel> All()
        {
            List <RoomViewModel> result = new List <RoomViewModel>();

            using (var db = new MinProContext())
            {
                result = (from roomItem in db.t_room
                          join officeItem in db.t_office
                          on roomItem.office_id equals officeItem.id
                          //where roomItem.id == id
                          select new RoomViewModel
                {
                    id = roomItem.id,
                    code = roomItem.code,
                    name = roomItem.name,
                    capacity = roomItem.capacity,
                    any_projector = roomItem.any_projector,
                    notes = roomItem.notes,
                    office_id = roomItem.office_id,
                    office_name = officeItem.name,
                    active = roomItem.active
                }).ToList();
            }

            return(result);
        }
Exemplo n.º 19
0
        public static ResponResultViewModel DeletePart(long id)
        {
            ResponResultViewModel result = new ResponResultViewModel();

            try
            {
                using (MinProContext db = new MinProContext())
                {
                    t_clazz clazz = db.t_clazz.Where(x => x.id == id).FirstOrDefault();

                    if (clazz == null)
                    {
                        result.Success = false;
                        result.Message = "Participant not found";
                    }
                    else
                    {
                        result.Entity = clazz;
                        db.t_clazz.Remove(clazz);
                        db.SaveChanges();
                    }
                }
            }

            catch (Exception e)
            {
                result.Success = false;
                result.Message = e.Message;
            }
            return(result);
        }
Exemplo n.º 20
0
        public static List <BatchViewModel> All(string code)
        {
            List <BatchViewModel> result = new List <BatchViewModel>();

            using (var db = new MinProContext())
            {
                result = (from b in db.t_batch
                          join t in db.t_technology on b.technology_id equals t.id
                          join r in db.t_trainer on b.trainer_id equals r.id
                          join o in db.t_room on b.room_id equals o.id
                          join y in db.t_bootcamp_type on b.bootcamp_type_id equals y.id
                          where b.is_delete == false
                          select new BatchViewModel
                {
                    id = b.id,
                    technology_id = b.technology_id,
                    techname = t.name,
                    name = b.name,
                    trainer_id = b.trainer_id,
                    trainername = r.name,
                    period_from = b.period_from,
                    period_to = b.period_to,
                    room_id = b.room_id,
                    bootcamp_type_id = b.bootcamp_type_id,
                    notes = b.notes,
                    is_delete = b.is_delete
                }).Where(x => x.techname.Contains(code) || x.name.Contains(code)).ToList();
            }
            return(result);
        }
Exemplo n.º 21
0
        public static ResponResultViewModel Deact(BatchViewModel model)
        {
            ResponResultViewModel result = new ResponResultViewModel();

            using (var db = new MinProContext())
            {
                t_batch batch = db.t_batch.Where(x => x.id == model.id).FirstOrDefault();
                batch.is_delete  = false;
                batch.deleted_by = 1;
                batch.deleted_on = DateTime.Now;
                batch.name       = model.name;

                try
                {
                    db.SaveChanges();
                    result.Entity = model;
                }
                catch (Exception e)
                {
                    result.Success = false;
                    result.Message = e.Message;
                }
            }
            return(result);
        }
Exemplo n.º 22
0
        public static ResponResultViewModel CreateHold(AssignmentViewModel entity)
        {
            //Untuk placement
            ResponResultViewModel result = new ResponResultViewModel();

            try
            {
                using (var db = new MinProContext())

                {
                    t_assignment asg = db.t_assignment.Where(o => o.id == entity.id).FirstOrDefault();
                    if (asg != null)
                    {
                        asg.biodata_id = entity.biodata_id;
                        asg.is_hold    = true;

                        asg.modified_by = 2;
                        asg.modified_on = DateTime.Now;

                        db.SaveChanges();

                        result.Entity = entity;
                    }
                }
            }
            catch (Exception ex)
            {
                result.Success = false;
                result.Message = ex.Message;
            }
            return(result);
        }
Exemplo n.º 23
0
        public static List <TrainerViewModel> All(string searchString)
        {
            List <TrainerViewModel> result = new List <TrainerViewModel>();

            using (var db = new MinProContext())
            {
                if (String.IsNullOrEmpty(searchString))
                {
                    result = (from tr in db.t_trainer
                              where tr.active == true
                              select new TrainerViewModel
                    {
                        id = tr.id,
                        name = tr.name,
                        notes = tr.notes,
                        active = tr.active
                    }).ToList();
                }
                else
                {
                    var s = from tr in db.t_trainer
                            where tr.active == true
                            select new TrainerViewModel
                    {
                        id     = tr.id,
                        name   = tr.name,
                        notes  = tr.notes,
                        active = tr.active
                    };
                    s      = s.Where(tr => tr.name.Contains(searchString));
                    result = s.ToList();
                }
            }
            return(result);
        }
Exemplo n.º 24
0
        public static ResponResultViewModel Update(MenuViewModel entity, long userid)
        {
            //untuk create & edit
            ResponResultViewModel result = new ResponResultViewModel();

            entity.code = GetNewMenu();
            try
            {
                using (var db = new MinProContext())
                {
                    if (entity.id == 0)
                    {
                        t_menu menu = new t_menu();
                        menu.code        = entity.code;
                        menu.title       = entity.title;
                        menu.description = entity.description;
                        menu.image_url   = entity.image_url;
                        menu.menu_order  = entity.menu_order;
                        menu.menu_parent = entity.menu_parent;
                        menu.menu_url    = entity.menu_url;
                        menu.created_by  = userid;
                        menu.created_on  = DateTime.Now;
                        menu.active      = entity.active;

                        db.t_menu.Add(menu);
                        db.SaveChanges();

                        result.Entity = menu;
                    }
                    else
                    {
                        t_menu menu = db.t_menu.Where(x => x.id == entity.id).FirstOrDefault();
                        if (menu != null)
                        {
                            menu.title       = entity.title;
                            menu.description = entity.description;
                            menu.image_url   = entity.image_url;
                            menu.menu_order  = entity.menu_order;
                            menu.menu_parent = entity.menu_parent;
                            menu.menu_url    = entity.menu_url;
                            menu.created_by  = userid;
                            menu.created_on  = DateTime.Now;
                            menu.active      = entity.active;

                            db.SaveChanges();
                            result.Entity = entity;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                result.Success = false;
                result.Message = e.Message;
            }
            return(result);
        }
Exemplo n.º 25
0
        public static List <AssignmentViewModel> All(string searchString)
        {
            List <AssignmentViewModel> result = new List <AssignmentViewModel>();

            using (var db = new MinProContext())
            {
                if (String.IsNullOrEmpty(searchString))
                {
                    result = (from c in db.t_assignment
                              join d in db.t_biodata on
                              c.biodata_id equals d.id
                              where c.is_delete == false
                              select new AssignmentViewModel
                    {
                        id = c.id,
                        bio_name = d.name,
                        biodata_id = c.biodata_id,
                        title = c.title,
                        start_date = c.start_date,
                        end_date = c.end_date,
                        description = c.description,
                        realization_date = c.realization_date,
                        notes = c.notes,
                        is_hold = c.is_hold,
                        is_done = c.is_done,
                        is_delete = c.is_delete,
                    }).ToList();
                }
                else
                {
                    var asg = from c in db.t_assignment
                              join d in db.t_biodata on
                              c.biodata_id equals d.id
                              where c.is_delete == false
                              select new AssignmentViewModel
                    {
                        id               = c.id,
                        bio_name         = d.name,
                        biodata_id       = c.biodata_id,
                        title            = c.title,
                        start_date       = c.start_date,
                        end_date         = c.end_date,
                        description      = c.description,
                        realization_date = c.realization_date,
                        notes            = c.notes,
                        is_hold          = c.is_hold,
                        is_done          = c.is_done,
                        is_delete        = c.is_delete,
                    };
                    asg    = asg.Where(o => o.bio_name.Contains(searchString));
                    result = asg.ToList();
                }
            }
            return(result);
        }
Exemplo n.º 26
0
        public static ResponResultViewModel Update2(TestimonyViewModel entity)
        {
            //untuk create dan edit
            ResponResultViewModel result = new ResponResultViewModel();

            try
            {
                using (var db = new MinProContext())
                {
                    if (entity.id == 0)
                    {
                        t_testimony testimony = new t_testimony();
                        testimony.title     = entity.title;
                        testimony.content   = entity.content;
                        testimony.is_delete = entity.is_delete;

                        testimony.created_by = 1;
                        testimony.created_on = DateTime.Now;

                        db.t_testimony.Add(testimony);
                        db.SaveChanges();
                        result.Entity = testimony;
                    }
                    else
                    {
                        t_testimony testimony = db.t_testimony.Where(o => o.id == entity.id).FirstOrDefault();
                        if (testimony != null)
                        {
                            testimony.title     = entity.title;
                            testimony.content   = entity.content;
                            testimony.is_delete = true;

                            testimony.created_by = 1;
                            testimony.created_on = DateTime.Now;

                            db.SaveChanges();

                            result.Entity = entity;
                        }
                        else
                        {
                            result.Success = false;
                            result.Message = "testimony not found!";
                        }
                    }
                }
            }
            catch (Exception e)
            {
                result.Success = false;
                result.Message = e.Message;
            }
            return(result);
        }
Exemplo n.º 27
0
        public static ResponResultViewModel Update2(TrainerViewModel entity)
        {
            //untuk create dan edit
            ResponResultViewModel result = new ResponResultViewModel();

            try
            {
                using (var db = new MinProContext())
                {
                    if (entity.id == 0)
                    {
                        t_trainer trainer = new t_trainer();
                        trainer.name   = entity.name;
                        trainer.notes  = entity.notes;
                        trainer.active = entity.active;

                        trainer.created_by = 1;
                        trainer.created_on = DateTime.Now;

                        db.t_trainer.Add(trainer);
                        db.SaveChanges();
                        result.Entity = trainer;
                    }
                    else
                    {
                        t_trainer trainer = db.t_trainer.Where(o => o.id == entity.id).FirstOrDefault();
                        if (trainer != null)
                        {
                            trainer.name   = entity.name;
                            trainer.notes  = entity.notes;
                            trainer.active = false;

                            trainer.created_by = 1;
                            trainer.created_on = DateTime.Now;

                            db.SaveChanges();

                            result.Entity = entity;
                        }
                        else
                        {
                            result.Success = false;
                            result.Message = "trainer not found!";
                        }
                    }
                }
            }
            catch (Exception e)
            {
                result.Success = false;
                result.Message = e.Message;
            }
            return(result);
        }
Exemplo n.º 28
0
        public static ResponResultViewModel Update(IdleViewModel entity)
        {
            //create - edit
            ResponResultViewModel result = new ResponResultViewModel();

            try
            {
                using (var db = new MinProContext())
                {
                    if (entity.id == 0)
                    {
                        t_idle_news idl = new t_idle_news();
                        idl.title       = entity.title;
                        idl.category_id = entity.category_id;
                        idl.content     = entity.content;
                        idl.is_publish  = false;
                        idl.created_by  = 1;
                        idl.created_on  = DateTime.Now;
                        idl.is_delete   = false;

                        db.t_idle_news.Add(idl);
                        db.SaveChanges();
                        result.Entity = entity;
                    }
                    else
                    {
                        t_idle_news idl = db.t_idle_news.Where(o => o.id == entity.id).FirstOrDefault();
                        if (idl != null)
                        {
                            idl.title       = entity.title;
                            idl.category_id = entity.category_id;
                            idl.content     = entity.content;
                            idl.modified_by = 1;
                            idl.modified_on = DateTime.Now;

                            db.SaveChanges();
                            result.Entity = entity;
                        }
                        else
                        {
                            result.Success = false;
                            result.Message = "Idle Not Found";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                result.Success = false;
                result.Message = ex.Message;
            }
            return(result);
        }
Exemplo n.º 29
0
        public static ResponResultViewModel Update(UserViewModel entity, long userid)
        {
            //untuk create & edit
            ResponResultViewModel result = new ResponResultViewModel();

            try
            {
                using (var db = new MinProContext())
                {
                    if (entity.id == 0)
                    {
                        t_user user = new t_user();
                        user.username     = entity.username;
                        user.password     = entity.password;
                        user.role_id      = entity.role_id;
                        user.mobile_flag  = entity.mobile_flag;
                        user.mobile_token = entity.mobile_token;
                        user.created_by   = userid;
                        user.created_on   = DateTime.Now;
                        user.active       = entity.active;

                        db.t_user.Add(user);
                        db.SaveChanges();

                        result.Entity = user;
                    }
                    else
                    {
                        t_user user = db.t_user.Where(x => x.id == entity.id).FirstOrDefault();
                        if (user != null)
                        {
                            user.username     = entity.username;
                            user.password     = entity.password;
                            user.role_id      = entity.role_id;
                            user.mobile_flag  = entity.mobile_flag;
                            user.mobile_token = entity.mobile_token;
                            user.modified_by  = userid;
                            user.modified_on  = DateTime.Now;
                            user.active       = entity.active;

                            db.SaveChanges();
                            result.Entity = entity;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                result.Success = false;
                result.Message = e.Message;
            }
            return(result);
        }
Exemplo n.º 30
0
        public static List <MonitoringViewModel> All(string searchString)
        {
            List <MonitoringViewModel> result = new List <MonitoringViewModel>();

            using (var db = new MinProContext())
            {
                if (String.IsNullOrEmpty(searchString))
                {
                    result = (from c in db.t_monitoring
                              join d in db.t_biodata on
                              c.biodata_id equals d.id
                              where c.is_delete == false
                              select new MonitoringViewModel
                    {
                        id = c.id,
                        bio_name = d.name,
                        biodata_id = c.biodata_id,
                        idle_date = c.idle_date,
                        last_project = c.last_project,
                        idle_reason = c.idle_reason,
                        placement_date = c.placement_date,
                        placement_at = c.placement_at,
                        notes = c.notes,

                        is_delete = c.is_delete,
                    }).ToList();
                }
                else
                {
                    var mon = from c in db.t_monitoring
                              join d in db.t_biodata on
                              c.biodata_id equals d.id
                              where c.is_delete == false
                              select new MonitoringViewModel
                    {
                        id             = c.id,
                        bio_name       = d.name,
                        biodata_id     = c.biodata_id,
                        idle_date      = c.idle_date,
                        last_project   = c.last_project,
                        idle_reason    = c.idle_reason,
                        placement_date = c.placement_date,
                        placement_at   = c.placement_at,
                        notes          = c.notes,
                        is_delete      = c.is_delete
                    };
                    mon    = mon.Where(o => o.bio_name.Contains(searchString));
                    result = mon.ToList();
                }
            }
            return(result);
        }