private bool CheckDesignationExist(DesignationModel designationModel) { using (var connection = new SqlConnection(connectionString)) { try { SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@designation", designationModel.Designation), new SqlParameter("@abbr", designationModel.Abbrivation), }; var data = SqlHelper.ExecuteReader ( connection, CommandType.StoredProcedure, "usp_CheckDesignationExist", parameters ); if (data != null && data.HasRows) { return(true); } } finally { SqlHelper.CloseConnection(connection); } } return(false); }
public bool AddDesignation(DesignationModel designationModel) { using (var connection = new SqlConnection(connectionString)) { try { SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@designation", designationModel.Designation), new SqlParameter("@abbr", designationModel.Abbrivation), }; var data = SqlHelper.ExecuteNonQuery ( connection, CommandType.StoredProcedure, "usp_AddDesignation", parameters ); if (data > 0) { return(true); } } finally { SqlHelper.CloseConnection(connection); } } throw new DataNotFound("Unable to Add Designation"); }
public ActionResult Designation(Sal_Dept_DesigModel objSal_Dept_Desig, string submit) { if (!String.IsNullOrEmpty(submit.Trim())) { DesignationModel objDesignationModel = new DesignationModel(); objDesignationModel.Designation = objSal_Dept_Desig.Designation; objDesignationModel.DesignationID = objSal_Dept_Desig.DesignationID; switch (submit.Trim()) { case "Update": objDesignationModel.AddEditDesignation(objDesignationModel, clsCommon.Update); BingModelData(objSal_Dept_Desig); break; case "Add": objDesignationModel.AddEditDesignation(objDesignationModel, clsCommon.Insert); BingModelData(objSal_Dept_Desig); break; case "Search": BingModelData(objSal_Dept_Desig); if (objSal_Dept_Desig.Designation != null || !String.IsNullOrEmpty(objSal_Dept_Desig.Designation)) { objSal_Dept_Desig.designationList = objDesignationModel.GetDesignationList(objSal_Dept_Desig.Designation).ToList(); } else { objSal_Dept_Desig.DesignationID = 0; } break; } } return(View("~/Views/sal_Dept_Desig/Index.cshtml", objSal_Dept_Desig)); }
public ActionResult Create(DesignationModel designationModel) { try { designationModel.RecLastUpdatedDt = DateTime.UtcNow; designationModel.RecLastUpdatedBy = User.Identity.GetUserId(); // TODO: Add insert logic here if (designationModel.DesignationId > 0) { designationService.UpdateDesignation(designationModel.MapClientToServer()); } else { designationModel.RecCreatedDt = DateTime.UtcNow; designationModel.RecCreatedBy = User.Identity.GetUserId(); designationService.AddDesignation(designationModel.MapClientToServer()); } TempData["message"] = new MessageViewModel { IsSaved = true, Message = "Your data has been saved successfully!" }; return(RedirectToAction("Create")); } catch (Exception ex) { return(View()); } }
public DesignationModel AddDesignation(DesignationModel model) { model.CreatedOn = DateTime.Now; db.Designation.Add(model); db.SaveChanges(); return(model); }
public ActionResult <DesignationModel> Delete(int id, [FromQuery] DesignationModel designation) { designation.DesignationId = id; var desig = _idesignation.RemoveDesignation(designation); return(Ok(desig)); }
public bool CheckDesignationName(DesignationModel designationModel) { var body = JsonConvert.SerializeObject(designationModel); var CheckDesignationName = ServerResponse.Invoke <bool>("api/designation/checkDesignationName", body, "POST"); return(CheckDesignationName); }
private void _Save() { msg = ""; DesignationModel dpt = new DesignationModel(); dpt.DesignationName = txtDesignationName.Text.Trim(); dpt.Description = txtDescription.Text.Trim(); if (ckbIsActive.Checked == true) { dpt.IsActive = true; } else { dpt.IsActive = false; } DesignationDAL objDal = new DesignationDAL(); if (btnSave.Text == "Save") { msg = objDal._insertUpdateDeleteDesignation(dpt, "Insert"); } else { dpt.DesignationId = Convert.ToInt32(HdnDesignationId.Value); msg = objDal._insertUpdateDeleteDesignation(dpt, "Update"); } if (msg != "") { _Refresh(); } }
public HttpResponseMessage DeleteDesignation(DesignationModel aDesignationModel) { try { if (this.ModelState.IsValid) { var result = service.DeleteDesignation(aDesignationModel); 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)); } }
public DesignationModel Edit(DesignationModel designationModel) { var body = JsonConvert.SerializeObject(designationModel); DesignationModel DesignationEdit = ServerResponse.Invoke <DesignationModel>("api/designation/edit?id=" + designationModel.Id, body, "POST"); return(DesignationEdit); }
public DesignationModel Delete(DesignationModel designationModel) { var body = JsonConvert.SerializeObject(designationModel); DesignationModel DesignationDelete = ServerResponse.Invoke <DesignationModel>("api/designation/Delete?id=" + designationModel.Id, body, "POST"); return(DesignationDelete); }
public DesignationModel GetById(int?id) { var body = ""; DesignationModel DesignationById = ServerResponse.Invoke <DesignationModel>("api/designation/getDetail?id=" + id, body, "get"); return(DesignationById); }
public DesignationModel Create(DesignationModel designationModel) { var body = JsonConvert.SerializeObject(designationModel); DesignationModel DesignationCreate = ServerResponse.Invoke <DesignationModel>("api/designation/create", body, "Post"); return(DesignationCreate); }
public ActionResult Create(DesignationModel model, bool continueEditing) { if (!_permissionService.Authorize("ManageDesignations")) { return(AccessDeniedView()); } // Check for duplicate classroom, if any var checkDesignation = _smsService.CheckDesignationExists(model.Name, model.Id); if (checkDesignation) { ModelState.AddModelError("Name", "A Designation with the same name already exists. Please choose a different name."); } if (ModelState.IsValid) { var objDesignation = model.ToEntity(); objDesignation.CreatedOn = objDesignation.ModifiedOn = DateTime.Now; objDesignation.UserId = _userContext.CurrentUser.Id; _smsService.InsertDesignation(objDesignation); SuccessNotification("Designation created successfully."); if (continueEditing) { return(RedirectToAction("Edit", new { id = objDesignation.Id })); } } else { return(View(model)); } return(RedirectToAction("List")); }
public object Post([FromBody] DesignationModel model) { var output = new ResponseDetail(); try { if (ModelState.IsValid) { var designationDetail = Mapper.Map <Designation>(model); var count = _designationService.CheckExistingDesignation(model.DesignationName); if (!count) { _designationService.CreateDesignation(designationDetail); output.Success = true; output.Message = "Designtion added successfully!"; } else { output.Success = false; output.Message = "Designation already exists!"; } return(output); } output.Success = false; return(output); } catch (Exception ex) { output.Success = false; output.Message = ex.Message; return(output); } }
public string _insertUpdateDeleteDesignation(DesignationModel Dpt, string _Action) { string _result = ""; try { _initObjects("SP_Designation"); cmd.Parameters.AddWithValue("@DesignationId", Dpt.DesignationId); cmd.Parameters.AddWithValue("@DesignationName", Dpt.DesignationName); cmd.Parameters.AddWithValue("@Description", Dpt.Description); cmd.Parameters.AddWithValue("@IsActive", Dpt.IsActive); cmd.Parameters.AddWithValue("@Action", _Action); _result = cmd.ExecuteScalar().ToString(); } catch (Exception ex) { CloseCon(); throw ex; } finally { CloseCon(); } return(_result); }
public async Task <JsonResult> SaveDesignation(DesignationModel designationModel) { JsonData <JsonStatus> data = new JsonData <JsonStatus>(new JsonStatus()); if (ModelState.IsValid) { if (designationModel.DesignationId > 0) { // update record. if (true == await _designation.UpdateDesignation(designationModel)) { data.Result.Status = true; } } else { // add new record. if (await _designation.CreateDesignation(designationModel) > 0) { data.Result.Status = true; } } } return(Json(data)); }
public ActionResult <DesignationViewModel> Get(string name) { _designationService.GetDesignation(name); DesignationModel designation = _designationService.GetDesignation(name); DesignationViewModel designationData = _mapper.Map <DesignationModel, DesignationViewModel>(designation); return(designationData); }
public DesignationModel GetDesignationById(int designationId) { DesignationGateway aDesignationGateway = new DesignationGateway(); DesignationModel aDesignationModel = new DesignationModel(); aDesignationModel = aDesignationGateway.GetDesignationById(designationId); return(aDesignationModel); }
//EDIT AND UPDATE THE DESIGNATION DETAILS public ViewResult EditDesignation(int id) { DesignationModel designationModel = new DesignationModel(); Designation designation = employeeBL.GetDesignationId(id); designationModel.DesignationId = designation.DesignationId; designationModel.DesignationName = designation.DesignationName; return(View(designationModel)); }
public async Task <bool> SaveDesignation(DesignationModel DesignationModel) { var result = await _mediator.Send <CommandResult <bool> >(new DesignationSaveCommand() { Model = DesignationModel }).ConfigureAwait(false); return(result.ResponseObj); }
public ActionResult Index() { AdminModel adminModel = new AdminModel(); //List<CityModel> objCityModel = new List<CityModel>(); Random rnd = new Random(); using (CityModel objCityModel = new CityModel()) { adminModel.cityList = objCityModel.GetCityList().OrderBy(o => rnd.Next()).Take(10).OrderBy(s => s.CityName).ToList(); } // = objCityModel.OrderBy(u => rnd.Next(objCityModel.Count)).Take(10).ToList().OrderBy(m=>m.CityName).ToList(); #region commented code Usefull do not delete //adminModel.stateList = objCityModel.OrderBy(k => k.StateName) // .GroupBy(item => item.RefStateID, (key, items) => new StateModel // { // StateID = items.First().RefStateID, // StateName = items.First().StateName, // CountryName = items.First().Country, // RefCountryID = items.First().RefCountryID // }).ToList(); //adminModel.countryList = objCityModel.OrderBy(c => c.Country) // .GroupBy(item => item.RefCountryID, (key, items) => new CountryModel // { // CountryID = items.First().RefCountryID, // Country = items.First().Country // }).ToList(); #endregion using (StateModel objState = new StateModel()) { adminModel.stateList = objState.GetStateList().OrderBy(o => rnd.Next()).Take(10).OrderBy(s => s.StateName).ToList(); } using (CountryModel objCountry = new CountryModel()) { adminModel.countryList = objCountry.GetCountryList().OrderBy(o => rnd.Next()).Take(10).OrderBy(o => o.Country).ToList(); } using (SalutationModel objSalutation = new SalutationModel()) { adminModel.salutationList = objSalutation.GetSalutationList().OrderBy(o => rnd.Next()).Take(10).OrderBy(cc => cc.Salutation).ToList(); } using (DepartmentModel objDepartment = new DepartmentModel()) { adminModel.departmentList = objDepartment.GetDepartmentList().OrderBy(o => rnd.Next()).Take(10).OrderBy(cc => cc.Department).ToList(); } using (DesignationModel objDesignation = new DesignationModel()) { adminModel.designationList = objDesignation.GetDesignationList().OrderBy(o => rnd.Next()).Take(10).OrderBy(cc => cc.Designation).ToList(); } return(View(adminModel)); }
public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DesignationModel DesignationModelById = Services.DesignationService.GetById(id); return(View(DesignationModelById)); }
public bool AddDesignation(DesignationViewModel designationViewModel) { DesignationModel designationModel = new DesignationModel { Designation = designationViewModel.Designation, Abbrivation = designationViewModel.Abbrivation }; return(_userProcessor.AddDesignation(designationModel)); }
public ActionResult Edit(DesignationModel designation) { if (ModelState.IsValid) { DesignationModel DesignationEdit = Services.DesignationService.Edit(designation); TempData["Success"] = "Data saved successfully!"; return(RedirectToAction("Index", "Designation")); } return(View(designation)); }
public ActionResult DeleteConfirmed(DesignationModel designation) { if (designation.Id > 0) { DesignationModel DesignationDelete = Services.DesignationService.Delete(designation); TempData["Success"] = "Data saved successfully!"; return(RedirectToAction("Index", "Designation")); } return(View(designation)); }
public ActionResult GetUpdatedUserDesignationList() { string Prefix = Request.Params["prefix"]; DesignationModel designationModel = new DesignationModel(Prefix); if (Request.Params["AddedDesignation"] != null) { designationModel.SelectedId = (designationModel.designations.Find(x => x.DesignationName == Convert.ToString(Request.Params["AddedDesignation"]))).DesignationId; } return(PartialView("CBPUserDesignationList", designationModel)); }
public ActionResult CreateDesignation(DesignationModel designationModel) { if (ModelState.IsValid) { Designation designation = new Designation(); designation.DesignationName = designationModel.DesignationName; employeeBL.AddDesignation(designation); return(RedirectToAction("DisplayDesignation")); } return(View()); }
public bool UpdateDesignation(DesignationViewModel designationViewModel) { DesignationModel designationModel = new DesignationModel { DesignationId = designationViewModel.DesignationId, Designation = designationViewModel.Designation, Abbrivation = designationViewModel.Abbrivation }; return(_userProcessor.UpdateDesignation(designationModel)); }
public ActionResult Create() { if (!_permissionService.Authorize("ManageDesignations")) { return(AccessDeniedView()); } var model = new DesignationModel(); return(View(model)); }