public IHttpActionResult UpdateDegree(DegreeModel model)
        {
            var response = new DataResponse <EntityDegrees>();

            if (ModelState.IsValid)
            {
                var entityDegree = new EntityDegrees();
                entityDegree.Id         = model.Id;
                entityDegree.IsActive   = model.IsActive;
                entityDegree.DegreeName = model.DegreeName;
                entityDegree.ShortCode  = model.ShortCode;
                entityDegree.UpdatedBy  = CurrentUserId;
                entityDegree.UpdatedOn  = System.DateTime.UtcNow;
                response = repository.UpdateDegree(entityDegree);
                return(Ok <DataResponse>(response));
            }
            else
            {
                var errorList = ModelState.Where(a => a.Value.Errors.Any()).Select(s => new
                {
                    Key     = s.Key.Split('.').Last(),
                    Message = s.Value.Errors[0].ErrorMessage
                });
                return(Ok <dynamic>(new { Status = HttpStatusCode.BadRequest, Model = errorList }));
            }
        }
        public DataResponse <EntityDegrees> Insert(EntityDegrees entity)
        {
            var response = new DataResponse <EntityDegrees>();

            try
            {
                base.DBInit();

                var model = new Database.LookupDegree
                {
                    DegreeName = entity.DegreeName,
                    ShortCode  = entity.ShortCode,
                    CreatedBy  = entity.CreatedBy,
                    CreatedOn  = System.DateTime.UtcNow,
                    IsActive   = entity.IsActive
                };

                if (base.DBSave(model) > 0)
                {
                    entity.Id = model.Id;
                    response.CreateResponse(entity, DataResponseStatus.OK);
                }
                else
                {
                    response.CreateResponse(DataResponseStatus.InternalServerError);
                }
            }
            catch (Exception ex)
            {
                ex.Log();
            }
            finally
            {
                base.DBClose();
            }
            return(response);
        }
        public DataResponse <EntityDegrees> UpdateDegree(EntityDegrees entity)
        {
            var response = new DataResponse <EntityDegrees>();

            try
            {
                base.DBInit();

                #region Prepare model
                var model = DBEntity.LookupDegrees.FirstOrDefault(a => a.Id == entity.Id);
                model.DegreeName = entity.DegreeName;
                model.ShortCode  = entity.ShortCode;
                model.IsActive   = entity.IsActive;
                model.UpdatedOn  = entity.UpdatedOn;
                model.UpdatedBy  = entity.UpdatedBy;
                #endregion

                if (base.DBSaveUpdate(model) > 0)
                {
                    return(GetDegreeById(model.Id));
                }
                else
                {
                    response.CreateResponse(DataResponseStatus.InternalServerError);
                }
            }
            catch (Exception ex)
            {
                ex.Log();
            }
            finally
            {
                base.DBClose();
            }
            return(response);
        }