// api/SurveyInfo public JsonResult <APIResultEntities <bool> > Post(SurveyInfoEntities surveyInfoEntities) { APIResultEntities <bool> rs = new APIResultEntities <bool>(); try { _iSurveyServices.CreateSurveyInfo(surveyInfoEntities); rs.Data = true; rs.ErrCode = ErrorCodeEntites.Success; rs.ErrDescription = string.Format(Constants.MSG_INSERT_SUCCESS, Constants.SurveyInfo); } catch (Exception ex) { rs.Data = false; rs.ErrCode = ErrorCodeEntites.Fail; rs.ErrDescription = ex.ToString(); } return(Json(rs)); }
/// <summary> /// Thêm mới 1 survey /// </summary> /// <param name="entity"></param> /// <returns></returns> public bool CreateSurveyInfo(SurveyInfoEntities entity) { SurveyInfo newitem = new SurveyInfo() { IdSurType = entity.IdSurType, IdSurvey = entity.IdSurvey, SurveyName = entity.SurveyName, Descriptions = entity.Descriptions, Images = entity.Images, CreatedDate = entity.CreatedDate, LastEditedAt = entity.LastEditedAt, LastEditedBy = entity.LastEditedBy, Status = entity.Status, OwnedUserID = entity.OwnedUserID }; _unit.SurveyinfoGenericType.Insert(newitem); _unit.Save(); return(true); }
/// <summary> /// sửa 1 survey /// </summary> /// <param name="id"></param> /// <param name="entity"></param> /// <returns></returns> public bool UpdateSurveyInfo(Guid id, SurveyInfoEntities entity) { bool success = false; var updateItem = _unit.SurveyinfoGenericType.GetByID(id); if (updateItem != null) { updateItem.IdSurType = entity.IdSurType; updateItem.SurveyName = entity.SurveyName; updateItem.Descriptions = entity.Descriptions; updateItem.Images = entity.Images; updateItem.CreatedDate = entity.CreatedDate; updateItem.LastEditedAt = entity.LastEditedAt; updateItem.LastEditedBy = entity.LastEditedBy; updateItem.Status = entity.Status; updateItem.OwnedUserID = entity.OwnedUserID; _unit.SurveyinfoGenericType.Update(updateItem); _unit.Save(); success = true; } return(success); }