Ejemplo n.º 1
0
        public ActionResult Show()
        {
            var dataSet       = Session["Users"] as tbl_Member;
            var educations    = db.tbl_Education.ToList();
            var educationList = new List <EducationModel>();

            foreach (var education in educations)
            {
                if (education.fk_UserID == dataSet.UserID)
                {
                    var eModel = new EducationModel
                    {
                        EducationID = education.EducationID,
                        SchoolName  = education.SchoolName,
                        Department  = education.Department,
                        StartDate   = education.StartDate,
                        FinishDate  = education.FinishDate,
                        fk_StatusID = education.fk_StatusID,
                        fk_UserID   = education.fk_UserID
                    };
                    educationList.Add(eModel);
                }
            }
            return(View(educationList));
        }
        protected void EditButton_Click(object sender, EventArgs e)
        {
            EducationModel model = new EducationModel()
            {
                CourseType           = CourseTypeTextBox.Text,
                YearOfPass           = CourseYearTextBox.Text,
                CourseSpecialization = CourseSpecialiazationTextBox.Text,
                EmployeeId           = Convert.ToInt32(EmployeeIdDropDownList.Text)
            };

            int EditEmployeeId = Convert.ToInt32(EditEmployeeIdInEducationDropDownList.Text);

            SqlConnection mysqlconnection = new SqlConnection()
            {
                ConnectionString = "Data Source = PRAJWOLPC;database = Pioneer_Employee_Database1;Integrated security = SSPI"
            };
            SqlCommand cmd = new SqlCommand("UPDATE [EducationDetail] SET[CourseType] = " +
                                            "'" + model.CourseType + "',[YearOfPass] = " + Convert.ToInt32(model.YearOfPass) + ",[CourseSpecilization] = '" + model.CourseSpecialization + "'WHERE EmployeeID = " + EditEmployeeId, mysqlconnection);

            mysqlconnection.Open();

            int result = cmd.ExecuteNonQuery();

            ClientScript.RegisterStartupScript(this.GetType(), "Operation was", "alert(' Education Details SUCCESSFULLY Edited');", true);
        }
Ejemplo n.º 3
0
        public HttpResponseMessage GetEducationModels(EducationModel model)
        {
            IUnitOfWork          uWork            = new UnitOfWork();
            IEducationRepository education        = new EducationRepository(uWork);
            IEducationService    educationService = new EducationService(education);

            try
            {
                if (this.ModelState.IsValid)
                {
                    var educationList = educationService.GetAllEducationList(model);
                    if (educationList != null)
                    {
                        return(Request.CreateResponse(HttpStatusCode.OK, educationList));
                    }
                    else
                    {
                        string message = "Error in getting Data";
                        return(Request.CreateErrorResponse(HttpStatusCode.Forbidden, message));
                    }
                }
                else
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.InnerException.Message));
            }
        }
Ejemplo n.º 4
0
        public async Task <ResponseModel> Insert(EducationModel model)
        {
            ResponseModel response = new ResponseModel();

            try
            {
                Education md = new Education();

                md.Name       = model.Name;
                md.Precedence = model.Precedence;
                md.IsActive   = model.IsActive;
                md.CreateBy   = base.UserId;
                md.CreateDate = DateTime.Now;
                md.Deleted    = false;

                await _context.EducationRepository.AddAsync(md).ConfigureAwait(true);

                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(response);
        }
Ejemplo n.º 5
0
        public JsonResult Delete(EducationModel model)
        {
            try
            {
                #region " [ Declaration ] "

                EducationService _service = new EducationService();

                #endregion

                #region " [ Main process ] "

                model.CreateBy   = UserID;
                model.DeleteBy   = UserID;
                model.DeleteDate = DateTime.Now;

                #endregion

                //Call to service
                return(this.Json(_service.Delete(model), JsonRequestBehavior.AllowGet));
            }
            catch (ServiceException serviceEx)
            {
                throw serviceEx;
            }
            catch (DataAccessException accessEx)
            {
                throw accessEx;
            }
            catch (Exception ex)
            {
                throw new ControllerException(FILE_NAME, "Delete", UserID, ex);
            }
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> GetSingle(Guid Id)
        {
            var AuthenticatedUserId = User.Identity.GetUserId();
            var Education           = await Context.UserEducation.FirstOrDefaultAsync(x => x.Id == Id && !x.IsRemoved && x.UserId == Guid.Parse(AuthenticatedUserId));

            if (Education != null)
            {
                var education = new EducationModel
                {
                    UniversityId        = Education.UniversityId,
                    Department          = Education.Department,
                    EducationId         = Id,
                    ActivitiesSocieties = Education.ActivitiesSocieties,
                    StartYear           = int.Parse(Education.StartYear),
                    EndYear             = int.Parse(Education.EndYear),
                };

                education.AreUniversityorDepartmentCanEditable = Education.AreUniNameOrDepartmentCanEditable();
                if (education.ActivitiesSocieties == null || education.ActivitiesSocieties == "undefined")
                {
                    education.ActivitiesSocieties = "";
                }

                return(Succes(null, education));
            }

            return(Error(null, null, null, 404));
        }
Ejemplo n.º 7
0
        public ActionResult Create()
        {
            try
            {
                #region " [ Declaration ] "

                EducationTypeService _typeService = new EducationTypeService();

                EducationModel model = new EducationModel()
                {
                    ID       = Guid.NewGuid(),
                    CreateBy = UserID,
                    Insert   = true
                };

                ViewBag.type = _typeService.GetAll(UserID);

                #endregion

                return(View(model));
            }
            catch (ServiceException serviceEx)
            {
                throw serviceEx;
            }
            catch (DataAccessException accessEx)
            {
                throw accessEx;
            }
            catch (Exception ex)
            {
                throw new ControllerException(FILE_NAME, "Create", UserID, ex);
            }
        }
Ejemplo n.º 8
0
        public ActionResult Edit(string id)
        {
            try
            {
                #region " [ Declaration ] "

                EducationTypeService _typeService = new EducationTypeService();
                EducationService     _service     = new EducationService();

                ViewBag.id   = id;
                ViewBag.type = _typeService.GetAll(UserID);

                #endregion

                // Call to service
                EducationModel model = _service.GetItemByID(new EducationModel()
                {
                    ID = new Guid(id), CreateBy = UserID, Insert = false
                });

                return(View(model));
            }
            catch (ServiceException serviceEx)
            {
                throw serviceEx;
            }
            catch (DataAccessException accessEx)
            {
                throw accessEx;
            }
            catch (Exception ex)
            {
                throw new ControllerException(FILE_NAME, "Edit", UserID, ex);
            }
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Delete
 /// </summary>
 /// <param name="model">model</param>
 /// <returns>ResponseStatusCodeHelper</returns>
 public ResponseStatusCodeHelper Delete(EducationModel model)
 {
     try
     {
         using (var _context = new TDHEntities())
         {
             PN_EDUCATION _md = _context.PN_EDUCATION.FirstOrDefault(m => m.id == model.ID && !m.deleted && m.created_by == model.CreateBy);
             if (_md == null)
             {
                 throw new DataAccessException(FILE_NAME, "Delete", model.CreateBy);
             }
             _md.deleted      = true;
             _md.deleted_by   = model.DeleteBy;
             _md.deleted_date = DateTime.Now;
             _context.PN_EDUCATION.Attach(_md);
             _context.Entry(_md).State = EntityState.Modified;
             _context.SaveChanges();
         }
     }
     catch (DataAccessException fieldEx)
     {
         throw fieldEx;
     }
     catch (Exception ex)
     {
         throw new ServiceException(FILE_NAME, "Delete", model.CreateBy, ex);
     }
     Notifier.Notification(model.CreateBy, Message.DeleteSuccess, Notifier.TYPE.Success);
     return(ResponseStatusCodeHelper.Success);
 }
        public HttpResponseMessage Get(int id)
        {
            EducationModel retr = null;

            try
            {
                Education edu = dbContext.Educations.Find(id);
                if (edu != null)
                {
                    EducationModel eduM = new EducationModel()
                    {
                        eduType = edu.Name,
                        ID      = edu.EducationID,
                    };
                    EmployeeController empCon = new EmployeeController();
                    for (int i = 0; i < edu.Employees.Count; i++)
                    {
                        EmployeeModel empMod = empCon.Get(edu.Employees.ToList()[i].EmployeeID);
                        eduM.employees.Add(empMod);
                    }
                    return(Request.CreateResponse(HttpStatusCode.OK, eduM));
                }
            }
            catch
            {
                return(Request.CreateResponse(HttpStatusCode.Conflict, retr));
            }

            return(Request.CreateResponse(HttpStatusCode.NotFound, retr));
        }
        public HttpResponseMessage Put(int id, [FromBody] EducationModel value)
        {
            try
            {
                Education ToBeUpdated = dbContext.Educations.Find(id);
                if (ToBeUpdated != null)
                {
                    ToBeUpdated.Name = value.eduType;
                    ToBeUpdated.Employees.Clear();
                    EmployeeController empCon = new EmployeeController();
                    for (int i = 0; i < value.employees.Count; i++)
                    {
                        Employee emp = dbContext.Employees.Find(value.employees[i].ID);
                        ToBeUpdated.Employees.Add(emp);
                    }
                    return(Request.CreateResponse(HttpStatusCode.OK, true));
                }
            }
            catch
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, false));
            }

            return(Request.CreateResponse(HttpStatusCode.NotModified, false));
        }
Ejemplo n.º 12
0
        public EducationModel GetEducation(string educationId)
        {
            string         query          = @"select id,teacherId,registrationNumber,coursId,CoursePassed,startDate,endDate 
								from  Обучение
								where id = {0};"                                ;
            EducationModel educationModel = null;

            using (SqlConnection con = new SqlConnection(_connectionString))
                using (SqlCommand command = new SqlCommand(string.Format(query, educationId)))
                {
                    con.Open();
                    command.Connection = con;
                    SqlDataReader reader = command.ExecuteReader();
                    if (reader.HasRows)             // если есть данные
                    {
                        educationModel = new EducationModel();
                        while (reader.Read())
                        {
                            educationModel.Id                 = reader.GetValue(0)?.ToString();
                            educationModel.TeacherId          = reader.GetValue(1)?.ToString();
                            educationModel.RegistrationNumber = reader.GetValue(2)?.ToString();
                            educationModel.CoursId            = reader.GetValue(3)?.ToString();
                            educationModel.CoursePassed       = reader.GetValue(4)?.ToString();
                        }
                    }
                    reader.Close();
                    con.Close();
                }

            return(educationModel);
        }
Ejemplo n.º 13
0
        public HttpResponseMessage DeleteEducation(EducationModel model)
        {
            IUnitOfWork          uWork            = new UnitOfWork();
            IEducationRepository education        = new EducationRepository(uWork);
            IEducationService    educationService = new EducationService(education);

            try
            {
                if (this.ModelState.IsValid)
                {
                    var result = educationService.DeleteEducation(model);
                    if (result != null)
                    {
                        return(Request.CreateResponse(HttpStatusCode.OK, result));
                    }
                    else
                    {
                        string message = "Not deleted successfully";
                        return(Request.CreateErrorResponse(HttpStatusCode.Forbidden, message));
                    }
                }
                else
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex));
            }
        }
Ejemplo n.º 14
0
        public string EditEducation(EducationModel EduModel)
        {
            int result = 0;

            try
            {
                sqlConnection          = OpenConnection();
                sqlCommand             = new SqlCommand();
                sqlCommand.Connection  = sqlConnection;
                sqlCommand.CommandType = CommandType.StoredProcedure;
                sqlCommand.CommandText = "uspEditEducationDetails";
                sqlCommand.Parameters.Add("@EmployeeID", SqlDbType.Int).Value               = EduModel.EmployeeID.ToString();
                sqlCommand.Parameters.Add("@CourseType", SqlDbType.VarChar).Value           = EduModel.CourseType;
                sqlCommand.Parameters.Add("@YearOfPass", SqlDbType.Int).Value               = EduModel.YearOfPass.ToString();
                sqlCommand.Parameters.Add("@CourseSpecialisation", SqlDbType.VarChar).Value = EduModel.CourseSpecialisation;
                result = sqlCommand.ExecuteNonQuery();
                if (result > 0)
                {
                    return("Details have been updated:");
                }

                return("Failed");
            }
            catch (Exception ex)
            {
                return("An error has been occured, please contact administrator:" + ex.Message);
            }

            finally
            {
                CloseConncetion(sqlConnection);
            }
        }
Ejemplo n.º 15
0
        public async Task <ResponseModel> Delete(EducationModel model)
        {
            ResponseModel response = new ResponseModel();

            try
            {
                Education md = await _context.EducationRepository.FirstOrDefaultAsync(m => m.Id == model.Id);

                if (!md.RowVersion.SequenceEqual(model.RowVersion))
                {
                    response.ResponseStatus = Core.CommonModel.Enums.ResponseStatus.OutOfDateData;
                    return(response);
                }

                md.Deleted    = true;
                md.UpdateBy   = base.UserId;
                md.UpdateDate = DateTime.Now;

                _context.EducationRepository.Update(md);

                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(response);
        }
Ejemplo n.º 16
0
        public async Task <ResponseModel> Item(int id)
        {
            ResponseModel response = new ResponseModel();

            try
            {
                Education md = await _context.EducationRepository.FirstOrDefaultAsync(m => m.Id == id);

                EducationModel model = new EducationModel()
                {
                    Id         = md.Id,
                    Name       = md.Name,
                    Precedence = md.Precedence,
                    IsActive   = md.IsActive,
                    RowVersion = md.RowVersion,
                };

                response.Result = model;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(response);
        }
 protected void EditButton_Click(object sender, EventArgs e)
 {
     try
     {
         EducationModel EduModel = new EducationModel()
         {
             EmployeeID           = Convert.ToInt32(EmployeeIDDropDownList.SelectedValue),
             CourseType           = CourseTypeTextBox.Text,
             YearOfPass           = Convert.ToInt32(YearOfPassTextBox.Text),
             CourseSpecialisation = CourseSpecialisationTextBox.Text
         };
         EducationAccess EduAccess = new EducationAccess();
         string          EditEdu   = EduAccess.EditEducation(EduModel);
         if (EditEdu.Equals("Success"))
         {
             {
                 Response.Write("<script>alert('Details have been Updated successfully');</script>");
             }
         }
     }
     catch (Exception Ex)
     {
         Response.Write("<script>alert('Error at EditEducation: '" + Ex.Message + ");</script>");
     }
 }
Ejemplo n.º 18
0
        public ActionResult Education(EducationModel edu)
        {
            LoginModel login = Session["Account"] as LoginModel;

            edu.IDEdu = user.getID(login.Username.ToString());
            user.addNewEducation(edu);
            return(View());
        }
Ejemplo n.º 19
0
 protected void UpdateLocales(Education entity, EducationModel model)
 {
     foreach (var localized in model.Locales)
     {
         _localizedEnitityHelperService.SaveLocalizedValue(entity,
                                                           x => x.Name,
                                                           localized.Name,
                                                           localized.LanguageId);
     }
 }
        protected void EmployeeIDDropDownList_SelectedIndexChanged(object sender, EventArgs e)
        {
            EducationModel  EduModel  = new EducationModel();
            EducationAccess EduAccess = new EducationAccess();

            EduModel = EduAccess.GetEmployee(Convert.ToInt32(EmployeeIDDropDownList.SelectedValue));
            CourseTypeTextBox.Text           = EduModel.CourseType;
            YearOfPassTextBox.Text           = EduModel.YearOfPass.ToString();
            CourseSpecialisationTextBox.Text = EduModel.CourseSpecialisation;
        }
Ejemplo n.º 21
0
        public async Task <IActionResult> EditView([FromQuery] EducationModel educationModel)
        {
            educationModel.Universities = await Context.University.Select(x => new SelectListItem()
            {
                Text = x.Name, Value = x.Id.ToString()
            }).ToListAsync();

            educationModel.ListYears();
            return(View(educationModel));
        }
Ejemplo n.º 22
0
        public ActionResult Education()
        {
            ViewData["AdditionHeader"] = "我的设置";
            EducationModel model = new EducationModel();

            model.CurUser       = CurrentUser;
            model.CurUserConfig = CurrentUserConfig;
            model.Educations    = Educations.GetEducationsByUID(model.CurUser.ID);
            return(View(model));
        }
        protected void EditEmployeeIdInEducationDropDownList_SelectedIndexChanged(object sender, EventArgs e)
        {
            EducationModel model = new EducationModel();

            model = GetEducationDetails(Convert.ToInt32(EditEmployeeIdInEducationDropDownList.Text));

            CourseTypeTextBox.Text            = model.CourseType;
            CourseYearTextBox.Text            = model.YearOfPass;
            CourseSpecialiazationTextBox.Text = model.CourseSpecialization;
            EmployeeIdDropDownList.Text       = Convert.ToString(model.EmployeeId);
        }
 public EducationModel UpdateEducation(EducationModel education)
 {
     try
     {
         return(_educationRepository.UpdateEducation(education));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 25
0
 public IHttpActionResult SaveEducation(EducationModel education)
 {
     try
     {
         return(Ok(_educationService.SaveEducation(education)));
     }
     catch (Exception ex)
     {
         return(InternalServerError(ex));
     }
 }
Ejemplo n.º 26
0
        public ActionResult Edit(int id, EducationModel edModel)
        {
            var education = db.tbl_Education.FirstOrDefault(e => e.EducationID == id);

            education.SchoolName  = edModel.SchoolName;
            education.Department  = edModel.Department;
            education.StartDate   = edModel.StartDate;
            education.FinishDate  = edModel.FinishDate;
            education.fk_StatusID = edModel.fk_StatusID;
            db.SaveChanges();
            return(RedirectToAction("Show"));
        }
Ejemplo n.º 27
0
        public async Task <IViewComponentResult> InvokeAsync()
        {
            var Model = new EducationModel();

            Model.ListYears();
            Model.Universities = await Context.University.Select(x => new SelectListItem()
            {
                Text = x.Name, Value = x.Id.ToString()
            }).ToListAsync();

            return(View(Model));
        }
Ejemplo n.º 28
0
        public EducationModel UpdateEducation(EducationModel educationModel)
        {
            var education = _dbContext.Educations
                            .FirstOrDefault(x => x.Id == educationModel.Id && x.RecordStatus == true);

            education.Name       = educationModel.Name;
            education.UpdateDate = DateTime.Now;

            _dbContext.SaveChanges();

            return(educationModel);
        }
Ejemplo n.º 29
0
        public ActionResult Edit(int id)
        {
            var education = db.tbl_Education.FirstOrDefault(e => e.EducationID == id);
            var change    = new EducationModel();

            change.SchoolName   = education.SchoolName;
            change.Department   = education.Department;
            change.StartDate    = education.StartDate;
            change.FinishDate   = education.FinishDate;
            change.fk_StatusID  = education.fk_StatusID;
            ViewBag.fk_StatusID = new SelectList(db.tbl_Status, "StatusID", "StatusName", education.fk_StatusID);
            return(View(change));
        }
Ejemplo n.º 30
0
        public EducationModel SaveEducation(EducationModel educationModel)
        {
            var education = new Education
            {
                Name = educationModel.Name
            };

            _dbContext.Educations.Add(education);
            _dbContext.SaveChanges();

            educationModel.Id = education.Id;
            return(educationModel);
        }