Beispiel #1
0
        //Get By Id
        public static BiodataViewModel ById(int Id)
        {
            BiodataViewModel result = new BiodataViewModel();

            using (var db = new XContext())
            {
                result = (from c in db.x_biodata
                          where c.id == Id
                          select new BiodataViewModel
                {
                    Id = c.id,
                    FullName = c.fullname,
                    NPM = c.identity_number,
                    Pob = c.pob,
                    Dob = c.dob,
                    Gender = c.gender,
                    Religion = c.religion,
                    Email = c.email,
                    Phone_number = c.phone_number1,
                    Faculty = c.faculty,
                    Major = c.major
                }).FirstOrDefault();
            }
            return(result != null ? result : new BiodataViewModel());
        }
Beispiel #2
0
        //RADIO BUTTON
        public static string GetGender(long Id)
        {
            string           gender = "";
            BiodataViewModel result = new BiodataViewModel();

            try
            {
                using (var db = new XBC_Context())
                {
                    result = (from b in db.t_biodata
                              where b.id == Id
                              select new BiodataViewModel
                    {
                        gender = b.gender
                    }).FirstOrDefault();

                    if (result != null)
                    {
                        gender = result.gender == null?"" : result.gender;
                    }
                }
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
            }
            return(gender);
        }
Beispiel #3
0
        public static BiodataViewModel ById(long id)
        {
            //id category.Id
            BiodataViewModel result = new BiodataViewModel();

            using (var db = new WFHContext())
            {
                result = (from v in db.x_address
                          join c in db.x_biodata
                          on v.biodata_id equals c.id
                          where v.biodata_id == id
                          select new BiodataViewModel
                {
                    id = v.id,
                    biodata_id = v.biodata_id,
                    fullname = c.fullname,
                    nick_name = c.nick_name,
                    pob = c.pob,
                    dob = c.dob,
                    gender = c.gender,

                    religion_id = c.religion_id,
                    high = c.high,
                    weight = c.weight,
                    nationality = c.nationality,
                    ethnic = c.ethnic,
                    hobby = c.hobby,
                    identity_type_id = c.identity_type_id,
                    identity_no = c.identity_no,
                    email = c.email,
                    phone_number1 = c.phone_number1,
                    phone_number2 = c.phone_number2,
                    parent_phone_number = c.parent_phone_number,
                    child_sequence = c.child_sequence,
                    how_many_brothers = c.how_many_brothers,
                    marital_status_id = c.marital_status_id,
                    marriage_year = c.marriage_year,
                    company_id = c.company_id,

                    address1 = v.address1,
                    postal_code1 = v.postal_code1,
                    rt1 = v.rt1,
                    rw1 = v.rw1,
                    kelurahan1 = v.kelurahan1,
                    kecamatan1 = v.kecamatan1,
                    region1 = v.region1,
                    address2 = v.address2,
                    postal_code2 = v.postal_code2,
                    rt2 = v.rt2,
                    rw2 = v.rw2,
                    kelurahan2 = v.kelurahan2,
                    kecamatan2 = v.kecamatan2,
                    region2 = v.region2
                }).FirstOrDefault();
            }

            return(result);
        }
Beispiel #4
0
        public ActionResult Deactivate(BiodataViewModel model)
        {
            ResponResultViewModel result = BiodataRepo.Update2(model);

            return(Json(new
            {
                success = result.Success,
                message = result.Message,
                entity = result.Entity
            }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult Delete(BiodataViewModel model)
        {
            ResponseResult result = BiodataRepo.Delete(model);

            return(Json(new
            {
                success = result.Success,
                message = result.ErrorMessage,
                entity = result.Entity
            }, JsonRequestBehavior.AllowGet));
        }
Beispiel #6
0
        //Delete
        public static ResponseResult Delete(BiodataViewModel entity)
        {
            ResponseResult result = new ResponseResult();

            try
            {
                using (var db = new XContext())
                {
                    x_biodata biodata = db.x_biodata
                                        .Where(o => o.id == entity.Id)
                                        .FirstOrDefault();

                    if (biodata != null)
                    {
                        biodata.delete_by = 1;
                        biodata.delete_on = DateTime.Now;

                        biodata.is_delete = true;

                        db.SaveChanges();

                        result.Entity = entity;
                    }
                    else
                    {
                        result.Success = false;
                        result.Message = "Data Not Found ! ";
                    }
                }
            }
            catch (Exception ex)
            {
                result.Success = false;
                result.Message = ex.Message;
            }
            return(result);
        }
Beispiel #7
0
        public static BiodataViewModel GetBiodata(int id)
        {
            BiodataViewModel result = new BiodataViewModel();

            using (var db = new MinProContext())
            {
                result = (from c in db.t_biodata
                          where c.id == id
                          select new BiodataViewModel
                {
                    id = c.id,
                    name = c.name,
                    gender = c.gender,
                    last_education = c.last_education,
                    graduation_year = c.graduation_year,
                    educational_level = c.educational_level,
                    majors = c.majors,
                    gpa = c.gpa,
                    bootcamp_test_type = c.bootcamp_test_type,
                    iq = c.iq,
                    du = c.du,
                    arithmetic = c.arithmetic,
                    nested_logic = c.nested_logic,
                    join_table = c.join_table,
                    tro = c.tro,
                    notes = c.notes,
                    interviewer = c.interviewer,
                    active = c.active,
                }).FirstOrDefault();
                if (result == null)
                {
                    result = new BiodataViewModel();
                }
            }
            return(result);
        }
Beispiel #8
0
        public static ResponResultViewModel Update2(BiodataViewModel entity)
        {
            ResponResultViewModel result = new ResponResultViewModel();

            try
            {
                using (var db = new MinProContext())
                {
                    t_biodata bio = db.t_biodata.Where(o => o.id == entity.id).FirstOrDefault();
                    if (bio != null)
                    {
                        bio.active = false;
                        db.SaveChanges();
                        result.Entity = entity;
                    }
                }
            }
            catch (Exception ex)
            {
                result.Success = false;
                result.Message = ex.Message;
            }
            return(result);
        }
Beispiel #9
0
        //Get By Id
        public static BiodataViewModel ById(long Id)
        {
            BiodataViewModel result = new BiodataViewModel();

            using (var db = new XBC_Context())
            {
                result = (from b in db.t_biodata
                          where b.id == Id && b.is_deleted == false
                          select new BiodataViewModel
                {
                    id = b.id,
                    name = b.name,
                    gender = b.gender,
                    last_education = b.last_education,
                    graduation_year = b.graduation_year,
                    educational_level = b.educational_level,
                    majors = b.majors,
                    gpa = b.gpa,
                    bootcamp_test_type = b.bootcamp_test_type,
                    iq = b.iq,
                    du = b.du,
                    arithmetic = b.arithmetic,
                    nested_logic = b.nested_logic,
                    join_table = b.join_table,
                    tro = b.tro,
                    notes = b.notes,
                    interviewer = b.interviewer
                }).FirstOrDefault();

                if (result == null)
                {
                    result = new BiodataViewModel();
                }
            }
            return(result);
        }
Beispiel #10
0
        //Create and Update
        public static ResponseResult Update(BiodataViewModel entity)
        {
            ResponseResult result = new ResponseResult();

            try
            {
                using (var db = new XContext())
                {
                    #region Create New / Insert
                    if (entity.Id == 0)
                    {
                        x_biodata biodata = new x_biodata();
                        biodata.identity_number = entity.NPM;
                        biodata.fullname        = entity.FullName;
                        biodata.pob             = entity.Pob;
                        biodata.dob             = entity.Dob;
                        biodata.gender          = entity.Gender;
                        biodata.religion        = entity.Religion;
                        biodata.email           = entity.Email;
                        biodata.phone_number1   = entity.Phone_number;
                        biodata.faculty         = entity.Faculty;
                        biodata.major           = entity.Major;

                        biodata.is_delete = false;

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

                        db.x_biodata.Add(biodata);
                        db.SaveChanges();

                        result.Entity = entity;
                    }
                    #endregion
                    #region Edit
                    else
                    {
                        x_biodata biodata = db.x_biodata
                                            .Where(o => o.id == entity.Id)
                                            .FirstOrDefault();

                        if (biodata != null)
                        {
                            biodata.identity_number = entity.NPM;
                            biodata.fullname        = entity.FullName;
                            biodata.pob             = entity.Pob;
                            biodata.dob             = entity.Dob;
                            biodata.gender          = entity.Gender;
                            biodata.religion        = entity.Religion;
                            biodata.email           = entity.Email;
                            biodata.phone_number1   = entity.Phone_number;
                            biodata.faculty         = entity.Faculty;
                            biodata.major           = entity.Major;

                            biodata.modified_by = 1;
                            biodata.modified_on = DateTime.Now;

                            db.SaveChanges();

                            result.Entity = entity;
                        }
                        else
                        {
                            result.Success = false;
                            result.Message = "Data Not Found ! ";
                        }
                    }
                    #endregion
                }
            }
            catch (Exception ex)
            {
                result.Success = false;
                result.Message = ex.Message;
            }
            return(result);
        }
Beispiel #11
0
        public static ResponResultViewModel Update(BiodataViewModel entity)
        {
            //Untuk create dan edit
            ResponResultViewModel result = new ResponResultViewModel();

            try
            {
                using (var db = new MinProContext())
                {
                    //Create
                    if (entity.id == 0)
                    {
                        t_biodata bi = new t_biodata();
                        bi.name              = entity.name;
                        bi.last_education    = entity.last_education;
                        bi.educational_level = entity.educational_level;
                        bi.graduation_year   = entity.graduation_year;
                        bi.majors            = entity.majors;
                        bi.gpa    = entity.gpa;
                        bi.active = entity.active;

                        bi.created_by = 1;
                        bi.created_on = DateTime.Now;
                        db.t_biodata.Add(bi);
                        db.SaveChanges();

                        result.Entity = bi;
                    }
                    //Edit
                    else
                    {
                        t_biodata bi = db.t_biodata.Where(o => o.id == entity.id).FirstOrDefault();
                        if (bi != null)
                        {
                            bi.name              = entity.name;
                            bi.last_education    = entity.last_education;
                            bi.educational_level = entity.educational_level;
                            bi.graduation_year   = entity.graduation_year;
                            bi.majors            = entity.majors;
                            bi.gpa    = entity.gpa;
                            bi.active = entity.active;

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

                            db.SaveChanges();

                            result.Entity = entity;
                        }
                        else
                        {
                            result.Success = false;
                            result.Message = "Biodata not Found!";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                result.Success = false;
                result.Message = ex.Message;
            }
            return(result);
        }
Beispiel #12
0
        public static ResponseResult Update(BiodataViewModel entity)
        {
            ResponseResult result = new ResponseResult();

            try
            {
                using (var db = new XBC_Context())
                {
                    //CREATE
                    if (entity.id == 0)
                    {
                        t_biodata bio = new t_biodata();
                        bio.name              = entity.name; //sesuai yg kita input di web
                        bio.last_education    = entity.last_education;
                        bio.educational_level = entity.educational_level;
                        bio.graduation_year   = entity.graduation_year;
                        bio.majors            = entity.majors;
                        bio.gpa        = entity.gpa;
                        bio.is_deleted = entity.is_deleted;

                        bio.created_by = entity.UserId;
                        bio.created_on = DateTime.Now;

                        db.t_biodata.Add(bio);
                        db.SaveChanges();

                        object data = new
                        {
                            bio.id,
                            bio.name,
                            bio.gender,
                            bio.last_education,
                            bio.graduation_year,
                            bio.educational_level,
                            bio.majors,
                            bio.gpa,
                            bio.bootcamp_test_type,
                            bio.iq,
                            bio.du,
                            bio.arithmetic,
                            bio.nested_logic,
                            bio.join_table,
                            bio.tro,
                            bio.notes,
                            bio.interviewer
                        };

                        var json = new JavaScriptSerializer().Serialize(data);

                        t_audit_log log = new t_audit_log();
                        log.type        = "Insert";
                        log.json_insert = json;

                        log.created_by = entity.UserId;
                        log.created_on = DateTime.Now;

                        db.t_audit_log.Add(log);
                        db.SaveChanges();

                        entity.id     = bio.id;
                        result.Entity = entity;
                    }
                    else //EDIT
                    {
                        t_biodata bio = db.t_biodata
                                        .Where(o => o.id == entity.id && o.is_deleted == false)
                                        .FirstOrDefault();

                        if (bio != null)
                        {
                            object data = new
                            {
                                bio.id,
                                bio.name,
                                bio.gender,
                                bio.last_education,
                                bio.graduation_year,
                                bio.educational_level,
                                bio.majors,
                                bio.gpa,
                                bio.bootcamp_test_type,
                                bio.iq,
                                bio.du,
                                bio.arithmetic,
                                bio.nested_logic,
                                bio.join_table,
                                bio.tro,
                                bio.notes,
                                bio.interviewer
                            };

                            var         json = new JavaScriptSerializer().Serialize(data);
                            t_audit_log log  = new t_audit_log();
                            log.type        = "Modify";
                            log.json_before = json;
                            log.created_by  = entity.UserId;
                            log.created_on  = DateTime.Now;

                            bio.name              = entity.name;
                            bio.gender            = entity.gender;
                            bio.last_education    = entity.last_education;
                            bio.graduation_year   = entity.graduation_year;
                            bio.educational_level = entity.educational_level;
                            bio.majors            = entity.majors;
                            bio.gpa = entity.gpa;
                            bio.bootcamp_test_type = entity.bootcamp_test_type;
                            bio.iq           = entity.iq;
                            bio.du           = entity.du;
                            bio.arithmetic   = entity.arithmetic;
                            bio.nested_logic = entity.nested_logic;
                            bio.join_table   = entity.join_table;
                            bio.tro          = entity.tro;
                            bio.notes        = entity.notes;
                            bio.interviewer  = entity.interviewer;

                            bio.modified_by = entity.UserId;
                            bio.modified_on = DateTime.Now;

                            object data2 = new
                            {
                                bio.id,
                                bio.name,
                                bio.gender,
                                bio.last_education,
                                bio.graduation_year,
                                bio.educational_level,
                                bio.majors,
                                bio.gpa,
                                bio.bootcamp_test_type,
                                bio.iq,
                                bio.du,
                                bio.arithmetic,
                                bio.nested_logic,
                                bio.join_table,
                                bio.tro,
                                bio.notes,
                                bio.interviewer
                            };

                            var json2 = new JavaScriptSerializer().Serialize(data2);
                            log.json_after = json2;
                            db.t_audit_log.Add(log);

                            db.SaveChanges();

                            result.Entity = entity;
                        }
                        else
                        {
                            result.Success      = false;
                            result.ErrorMessage = "Biodata not found!";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                result.Success      = false;
                result.ErrorMessage = ex.Message;
            }
            return(result);
        }
Beispiel #13
0
        //DELETE
        public static ResponseResult Delete(BiodataViewModel entity)
        {
            ResponseResult result = new ResponseResult();

            try
            {
                using (var db = new XBC_Context())
                {
                    t_biodata bio = db.t_biodata
                                    .Where(o => o.id == entity.id)
                                    .FirstOrDefault();

                    if (bio != null)
                    {
                        object data = new
                        {
                            bio.id,
                            bio.name,
                            bio.gender,
                            bio.last_education,
                            bio.graduation_year,
                            bio.educational_level,
                            bio.majors,
                            bio.gpa,
                            bio.bootcamp_test_type,
                            bio.iq,
                            bio.du,
                            bio.arithmetic,
                            bio.nested_logic,
                            bio.join_table,
                            bio.tro,
                            bio.notes,
                            bio.interviewer,
                            bio.is_deleted
                        };

                        var         json = new JavaScriptSerializer().Serialize(data);
                        t_audit_log log  = new t_audit_log();
                        log.type        = "Modify";
                        log.json_before = json;
                        log.created_by  = entity.UserId;
                        log.created_on  = DateTime.Now;

                        bio.is_deleted = true;
                        bio.deleted_by = entity.UserId;
                        bio.deleted_on = DateTime.Now;

                        object data2 = new
                        {
                            bio.id,
                            bio.name,
                            bio.gender,
                            bio.last_education,
                            bio.graduation_year,
                            bio.educational_level,
                            bio.majors,
                            bio.gpa,
                            bio.bootcamp_test_type,
                            bio.iq,
                            bio.du,
                            bio.arithmetic,
                            bio.nested_logic,
                            bio.join_table,
                            bio.tro,
                            bio.notes,
                            bio.interviewer,
                            bio.is_deleted
                        };

                        var json2 = new JavaScriptSerializer().Serialize(data2);
                        log.json_after = json2;
                        db.t_audit_log.Add(log);

                        db.SaveChanges();

                        result.Entity = entity;
                    }
                    else
                    {
                        result.Success      = false;
                        result.ErrorMessage = "Biodata not found!";
                    }
                }
            }
            catch (Exception ex)
            {
                result.Success      = false;
                result.ErrorMessage = ex.Message;
            }
            return(result);
        }