예제 #1
0
        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);
        }
예제 #2
0
 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));
        }
예제 #4
0
        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());
            }
        }
예제 #5
0
 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));
        }
예제 #7
0
        public bool CheckDesignationName(DesignationModel designationModel)
        {
            var body = JsonConvert.SerializeObject(designationModel);
            var CheckDesignationName = ServerResponse.Invoke <bool>("api/designation/checkDesignationName", body, "POST");

            return(CheckDesignationName);
        }
예제 #8
0
        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();
            }
        }
예제 #9
0
 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));
     }
 }
예제 #10
0
        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);
        }
예제 #11
0
        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);
        }
예제 #12
0
        public DesignationModel GetById(int?id)
        {
            var body = "";
            DesignationModel DesignationById = ServerResponse.Invoke <DesignationModel>("api/designation/getDetail?id=" + id, body, "get");

            return(DesignationById);
        }
예제 #13
0
        public DesignationModel Create(DesignationModel designationModel)
        {
            var body = JsonConvert.SerializeObject(designationModel);
            DesignationModel DesignationCreate = ServerResponse.Invoke <DesignationModel>("api/designation/create", body, "Post");

            return(DesignationCreate);
        }
예제 #14
0
        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"));
        }
예제 #15
0
        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);
            }
        }
예제 #16
0
        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);
        }
예제 #17
0
        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));
        }
예제 #18
0
        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));
        }
예제 #21
0
        public async Task <bool> SaveDesignation(DesignationModel DesignationModel)
        {
            var result = await _mediator.Send <CommandResult <bool> >(new DesignationSaveCommand()
            {
                Model = DesignationModel
            }).ConfigureAwait(false);

            return(result.ResponseObj);
        }
예제 #22
0
        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));
        }
예제 #24
0
        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));
 }
예제 #27
0
        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());
 }
예제 #29
0
        public bool UpdateDesignation(DesignationViewModel designationViewModel)
        {
            DesignationModel designationModel = new DesignationModel
            {
                DesignationId = designationViewModel.DesignationId,
                Designation   = designationViewModel.Designation,
                Abbrivation   = designationViewModel.Abbrivation
            };

            return(_userProcessor.UpdateDesignation(designationModel));
        }
예제 #30
0
        public ActionResult Create()
        {
            if (!_permissionService.Authorize("ManageDesignations"))
            {
                return(AccessDeniedView());
            }

            var model = new DesignationModel();

            return(View(model));
        }