public BaseResponse InsertProgramName([FromBody] ProgramNamesRequest request) { BaseResponse response = new BaseResponse(); using (TransactionScope scope = new TransactionScope()) { try { if (!BAplication.ValidateAplicationToken(request.ApplicationToken)) { response.Code = "2"; response.Message = Messages.ApplicationTokenNoAutorize; return(response); } string webRoot = _env.ContentRootPath; string rootPath = _appSettings.Value.rootPath; string ProjectPath = _appSettings.Value.ProjectPath; BaseRequest baseRequest = new BaseRequest(); foreach (MProgramName model in request.ProgramNames) { MProgramName programName = new MProgramName(); programName.ProjectCode = model.ProjectCode; programName.ProgramName = model.ProgramName; programName.DonorCode = model.DonorCode; programName.ProjectDetails = model.ProjectDetails; programName.Sector = model.Sector; programName.TaskManager = model.TaskManager; BProgramName.Insert(programName); } response.Code = "0"; response.Message = "Success"; scope.Complete(); } catch (Exception ex) { response.Code = "2"; response.Message = ex.Message; scope.Dispose(); } } return(response); }
public ActionResult Register(LoadProgamViewModel model, HttpPostedFileBase imageFile) { JSonResult objResult = new JSonResult(); string response = string.Empty; try { Session objSession = new Session() { UserId = AutenticationManager.GetUser().IdUsuario, }; List <MProgramName> entList = new List <MProgramName>(); List <ModelProgramResult> entListData = new List <ModelProgramResult>(); entListData = (List <ModelProgramResult>)Session["ListPrograms"]; foreach (ModelProgramResult item in entListData) { MProgramName mFund = new MProgramName(); mFund.ProjectCode = item.ProjectCode; mFund.ProgramName = item.ProgramName; mFund.DonorCode = item.DonorCode; mFund.ProjectDetails = item.ProjectDetails; mFund.TaskManager = item.TaskManager; mFund.Sector = item.Sector; entList.Add(mFund); } response = new WebApiProgram().InsertProgramName(entList, objSession); string statusCode = response.Split('|')[0]; string statusMessage = response.Split('|')[1]; objResult.isError = statusCode.Equals("2"); objResult.message = string.Format(MessageResource.SaveSuccess, "Program Names");; } catch (Exception ex) { objResult.message = string.Format(MessageResource.SaveError + "Error :" + ex.Message, "Program Names"); } return(Json(objResult)); }
public static int Insert(MProgramName ent) { using (SqlConnection con = new SqlConnection(ConnectionDB.GetConnectionString())) { SqlCommand cmd = new SqlCommand("sp_ProgramName_Ins", con); cmd.CommandTimeout = 0; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@IProjectCode", SqlDbType.VarChar).Value = ent.ProjectCode; cmd.Parameters.Add("@IProgramName", SqlDbType.VarChar).Value = ent.ProgramName; cmd.Parameters.Add("@IDonorCode", SqlDbType.VarChar).Value = ent.DonorCode; cmd.Parameters.Add("@IProjectDetails", SqlDbType.VarChar).Value = ent.ProjectDetails; cmd.Parameters.Add("@ISector", SqlDbType.VarChar).Value = ent.Sector; cmd.Parameters.Add("@ITaskManager", SqlDbType.VarChar).Value = ent.TaskManager; con.Open(); cmd.ExecuteNonQuery(); con.Close(); } return(0); }
public static List <MProgramName> List() { List <MProgramName> lisQuery = new List <MProgramName>(); using (SqlConnection con = new SqlConnection(ConnectionDB.GetConnectionString())) { try { SqlCommand cmd = new SqlCommand("sp_ProgramName_Lis", con); cmd.CommandTimeout = 0; cmd.CommandType = CommandType.StoredProcedure; con.Open(); using (var reader = cmd.ExecuteReader()) { while (reader.Read()) { MProgramName entRow = new MProgramName(); entRow.ProgramNameId = Convert.ToInt32(reader["ProgramNameId"]); entRow.ProjectCode = Convert.ToString(reader["ProjectCode"]); entRow.ProgramName = Convert.ToString(reader["ProgramName"]); entRow.DonorCode = Convert.ToString(reader["DonorCode"]); lisQuery.Add(entRow); } } con.Close(); } catch (Exception ex) { lisQuery = null; } } return(lisQuery); }
public static int Insert(MProgramName ent) { return(DAProgramName.Insert(ent)); }