public IHttpActionResult Postemployee_details(employee_details employee_details)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.employee_details.Add(employee_details);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (employee_detailsExists(employee_details.employee_id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = employee_details.employee_id }, employee_details));
        }
Пример #2
0
 public ActionResult Save(IEnumerable <employee_details> empObject)
 {
     try
     {
         foreach (var item in empObject)
         {
             if (item.pkid == 0)
             {
                 employee_details newEntry = new employee_details();
                 newEntry.name        = item.name;
                 newEntry.salary      = item.salary;
                 newEntry.designation = item.designation;
                 newEntry.yearofexp   = item.yearofexp;
                 newEntry.joineddate  = !string.IsNullOrEmpty(item.joineddate.ToString()) ? Convert.ToDateTime(item.joineddate.ToString()) : (DateTime?)null;
                 db.employee_details.Add(newEntry);
                 db.SaveChanges();
             }
             else
             {
                 employee_details updateEntry = db.employee_details.Where(x => x.pkid == item.pkid).FirstOrDefault();
                 updateEntry.name        = item.name;
                 updateEntry.salary      = item.salary;
                 updateEntry.designation = item.designation;
                 updateEntry.yearofexp   = item.yearofexp;
                 updateEntry.joineddate  = !string.IsNullOrEmpty(item.joineddate.ToString()) ? Convert.ToDateTime(item.joineddate.ToString()) : (DateTime?)null;
                 db.SaveChanges();
             }
         }
     }
     catch (Exception Ex)
     {
         throw new Exception(Ex.Message);
     }
     return(Json(JsonRequestBehavior.AllowGet));
 }
        public IHttpActionResult Putemployee_details(string id, employee_details employee_details)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != employee_details.employee_id)
            {
                return(BadRequest());
            }

            db.Entry(employee_details).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!employee_detailsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #4
0
 /// <summary>
 /// Converts from.
 /// </summary>
 /// <param name="employee_details">The employee details.</param>
 /// <returns>employee_detailsModel.</returns>
 public static employee_detailsModel ConvertFrom(employee_details employee_details)
 {
     return(new employee_detailsModel()
     {
         employee_code = employee_details.employee_code,
         roleID = employee_details.roleID,
         DeptID = employee_details.DeptID,
         firstname = employee_details.firstname,
         middlename = employee_details.middlename,
         surname = employee_details.surname,
         gender = employee_details.gender,
         date_of_birth = employee_details.date_of_birth,
         date_of_joining = employee_details.date_of_joining,
         marital_status = employee_details.marital_status,
         marriage_anniversary = employee_details.marriage_anniversary,
         blood_group = employee_details.blood_group,
         mobile_number = employee_details.mobile_number,
         alternate_number = employee_details.alternate_number,
         emergency_number = employee_details.emergency_number,
         home_number = employee_details.home_number,
         email_id = employee_details.email_id,
         permanent_address = employee_details.permanent_address,
         temporary_address = employee_details.temporary_address,
         aadhar_card = employee_details.aadhar_card,
         passport_number = employee_details.passport_number,
         passport_validity = employee_details.passport_validity,
         pan_card = employee_details.pan_card,
         election_card = employee_details.election_card,
         single_bank_account = employee_details.single_bank_account,
         ifs_code = employee_details.ifs_code,
         vehicle_number = employee_details.vehicle_number,
         allergies = employee_details.allergies,
         known_ailments = employee_details.known_ailments
     });
 }
        public IHttpActionResult Getemployee_details(string id)
        {
            employee_details employee_details = db.employee_details.Find(id);

            if (employee_details == null)
            {
                return(NotFound());
            }

            return(Ok(employee_details));
        }
        public IHttpActionResult Deleteemployee_details(string id)
        {
            employee_details employee_details = db.employee_details.Find(id);

            if (employee_details == null)
            {
                return(NotFound());
            }

            db.employee_details.Remove(employee_details);
            db.SaveChanges();

            return(Ok(employee_details));
        }
        static void Main(string[] args)
        {
            var         reader   = new StreamReader("C:\\Users\\suraj\\Desktop\\100_Records.csv");
            var         csv      = new CsvReader(reader);
            List <data> datalist = new List <data>();

            csv.Read();
            csv.ReadHeader();
            while (csv.Read())
            {
                var record = new data
                {
                    emp_id          = csv.GetField <int>("Emp_ID"),
                    First_Name      = csv.GetField("First_Name"),
                    Last_Name       = csv.GetField("Last_Name"),
                    DOB             = csv.GetField("Date_of_Birth"),
                    Date_of_joining = csv.GetField("Date_of_Joining"),
                    location        = csv.GetField("location")
                };

                datalist.Add(record);
            }

            var employeedata = new employee_details();

            try
            {
                foreach (var employee in datalist)
                {
                    employeedata.emp_id          = employee.emp_id;
                    employeedata.name            = employee.First_Name + " " + employee.Last_Name;
                    employeedata.DOB             = employee.DOB;
                    employeedata.age             = 35;
                    employeedata.date_of_joining = employee.Date_of_joining;
                    employeedata.location        = employee.location;

                    using (var dbCtx = new workshopEntities())
                    {
                        dbCtx.employee_details.Add(employeedata);
                        dbCtx.SaveChanges();
                    }
                }
                displaydata();
                Console.ReadKey();
            }
            catch (DbUpdateException e)
            {
                displaydata();
            }
        }
Пример #8
0
 public ActionResult Delete(int pkid)
 {
     try
     {
         employee_details delEntry = db.employee_details.Where(x => x.pkid == pkid).FirstOrDefault();
         if (delEntry != null)
         {
             db.employee_details.Remove(delEntry);
             db.SaveChanges();
         }
     }
     catch (Exception Ex)
     {
         throw new Exception(Ex.Message);
     }
     return(Json(JsonRequestBehavior.AllowGet));
 }
Пример #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            employee_details e1 = new employee_details {
                id = 1, name = "Keerthi", age = 21
            };
            employee_details e2 = new employee_details {
                id = 2, name = "Karthik", age = 22
            };
            employee_details e3 = new employee_details {
                id = 3, name = "pooja", age = 21
            };

            List <employee_details> emp_list = new List <employee_details>();

            emp_list.Add(e1);
            emp_list.Add(e2);

            //serailizing c# object to jason object
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            string jason = serializer.Serialize(emp_list);

            Response.Write(jason);
        }
Пример #10
0
 public void EditPostforEmployeeDetails(employee_detailsModel Employee_detailsModel, employee_details entity)
 {
     entity.employee_code        = Employee_detailsModel.employee_code;
     entity.designation          = Employee_detailsModel.designation;
     entity.department           = Employee_detailsModel.department;
     entity.firstname            = Employee_detailsModel.firstname;
     entity.middlename           = Employee_detailsModel.middlename;
     entity.surname              = Employee_detailsModel.surname;
     entity.gender               = Employee_detailsModel.gender;
     entity.date_of_birth        = Employee_detailsModel.date_of_birth;
     entity.date_of_joining      = Employee_detailsModel.date_of_joining;
     entity.marital_status       = Employee_detailsModel.marital_status;
     entity.marriage_anniversary = Employee_detailsModel.marriage_anniversary;
     entity.blood_group          = Employee_detailsModel.blood_group;
     entity.mobile_number        = Employee_detailsModel.mobile_number;
     entity.home_number          = Employee_detailsModel.home_number;
     entity.alternate_number     = Employee_detailsModel.alternate_number;
     entity.emergency_number     = Employee_detailsModel.emergency_number;
     entity.email_id             = Employee_detailsModel.email_id;
     entity.permanent_address    = Employee_detailsModel.permanent_address;
     entity.temporary_address    = Employee_detailsModel.temporary_address;
     entity.aadhar_card          = Employee_detailsModel.aadhar_card;
     entity.pan_card             = Employee_detailsModel.pan_card;
     entity.passport_number      = Employee_detailsModel.passport_number;
     entity.passport_validity    = Employee_detailsModel.passport_validity;
     entity.election_card        = Employee_detailsModel.election_card;
     entity.vehicle_number       = Employee_detailsModel.vehicle_number;
     entity.single_bank_account  = Employee_detailsModel.single_bank_account;
     entity.ifs_code             = Employee_detailsModel.ifs_code;
     entity.allergies            = Employee_detailsModel.allergies;
     entity.known_ailments       = Employee_detailsModel.known_ailments;
     entity.roleID               = Employee_detailsModel.roleID;
     entity.DeptID               = Employee_detailsModel.DeptID;
 }
Пример #11
0
 public Model2()
 {
     Fatherdetails = new family_details()
     {
         member = "Father"
     };
     Motherdetails = new family_details()
     {
         member = "Mother"
     };
     Brotherdetails = new family_details()
     {
         member = "Brother"
     };
     Sisterdetails = new family_details()
     {
         member = "Sister"
     };
     Spousedetails = new family_details()
     {
         member = "Spouse"
     };
     Childrendetails = new family_details()
     {
         member = "Children"
     };
     Certification1 = new certifications()
     {
         cert_type = "1"
     };
     Certification2 = new certifications()
     {
         cert_type = "2"
     };
     Certification3 = new certifications()
     {
         cert_type = "3"
     };
     Certification4 = new certifications()
     {
         cert_type = "4"
     };
     Prevemploy1 = new prev_employ_1()
     {
         employment_ref = "1"
     };
     Prevemploy2 = new prev_employ_1()
     {
         employment_ref = "2"
     };
     Prevemploy3 = new prev_employ_1()
     {
         employment_ref = "3"
     };
     Prevemploy4 = new prev_employ_1()
     {
         employment_ref = "4"
     };
     Prevemploy5 = new prev_employ_1()
     {
         employment_ref = "5"
     };
     Reference1 = new references()
     {
         ref_type = "1"
     };
     Reference2 = new references()
     {
         ref_type = "2"
     };
     Feedback        = new feedback();
     Employeedetails = new employee_details();
 }