public void DeleteTechnology(int technology) { try { if (ValidationHelper.IfTechnologyExist(technology)) { CompanyDBDataContext dc = new CompanyDBDataContext(); List <TechProjectMap> techProjectList = (from techProject in dc.TechProjectMaps where techProject.TechID == technology select techProject).ToList(); List <TechTaskMap> techTaskList = (from techTask in dc.TechTaskMaps where techTask.TechID == technology select techTask).ToList(); TechnologyMaster technologyToDelete = (from tech in dc.TechnologyMasters where tech.TechID == technology select tech).First(); dc.TechTaskMaps.DeleteAllOnSubmit(techTaskList); dc.TechProjectMaps.DeleteAllOnSubmit(techProjectList); dc.TechnologyMasters.DeleteOnSubmit(technologyToDelete); dc.SubmitChanges(); Console.WriteLine("Technology Deleted Sucessfully");; } else { throw new Exception(QueryResource.TechnologyNotexist); } } catch (Exception ex) { throw ex; } }
public void DeleteTechnology(int technologyID) { try { List <ProjectTechnology> projectTechnologies = (from projectTech in dataContext.ProjectTechnologies where projectTech.TechnologyId == technologyID select projectTech).ToList(); if (projectTechnologies.Count > 0) { dataContext.ProjectTechnologies.DeleteAllOnSubmit(projectTechnologies); dataContext.SubmitChanges(); } List <TaskTechnology> taskTechnology = (from taskTech in dataContext.TaskTechnologies where taskTech.TechnologyId == technologyID select taskTech).ToList(); if (taskTechnology.Count > 0) { dataContext.TaskTechnologies.DeleteAllOnSubmit(taskTechnology); dataContext.SubmitChanges(); } TechnologyMaster technology = (from tech in dataContext.TechnologyMasters where tech.TechnologyId == technologyID select tech).FirstOrDefault(); if (technology != null) { dataContext.TechnologyMasters.DeleteOnSubmit(technology); dataContext.SubmitChanges(); } } catch (Exception ex) { throw ex; } }
public ActionResult DeleteConfirmed(int id) { TechnologyMaster technologyMaster = db.TechnologyMasters.Find(id); db.TechnologyMasters.Remove(technologyMaster); db.SaveChanges(); return(RedirectToAction("Index")); }
public static BOTechnology ConvertTechnologyToBOTechnology(TechnologyMaster technology) { BOTechnology boTechnology = new BOTechnology(); boTechnology.TechnologyId = technology.TechnologyId; boTechnology.TechnologyName = technology.TechnologyName; return(boTechnology); }
public static TechnologyMaster ConvertBOTechnologyToTechnology(BOTechnology boTechnology) { TechnologyMaster technology = new TechnologyMaster(); technology.TechnologyId = boTechnology.TechnologyId; technology.TechnologyName = boTechnology.TechnologyName; return(technology); }
public ActionResult Edit([Bind(Include = "TechId,TechName")] TechnologyMaster technologyMaster) { if (ModelState.IsValid) { db.Entry(technologyMaster).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(technologyMaster)); }
public static string CheckCompulsoryTechnologyColumn(TechnologyMaster technology) { if (string.IsNullOrEmpty(technology.TechnologyName)) { return(CMResources.TechnologyNameMissing); } else { return(CMResources.AllFieldsPresent); } }
public void AddTechnology(BOTechnology boTechnology) { try { TechnologyMaster technology = BusinessLayerHelper.ConvertBOTechnologyToTechnology(boTechnology); dataLayer.AddTechnology(technology); } catch (Exception ex) { throw ex; } }
public string checkCompulsoryTechnologyColumn() { TechnologyMaster tech = new TechnologyMaster(); if (string.IsNullOrEmpty(tech.TechName)) { return("Tech Name Missing"); } else { return("All field present"); } }
// GET: admin/TechnologyMasters/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TechnologyMaster technologyMaster = db.TechnologyMasters.Find(id); if (technologyMaster == null) { return(HttpNotFound()); } return(View(technologyMaster)); }
public static string CheckCompulsoryTechnologyColumn(TechnologyMaster technology) { if (string.IsNullOrEmpty(technology.TechName)) { return(QueryResource.TechNameMissing); } else if (technology.TechID == 0) { return(QueryResource.TechIdMissing); } else { return(QueryResource.AllFieldsPresent); } }
public void AddTechnology(TechnologyMaster technology) { CompanyDBDataContext dc = new CompanyDBDataContext(); string dataValidate = ValidationHelper.CheckCompulsoryTechnologyColumn(technology); if (dataValidate != QueryResource.AllFieldsPresent) { throw new Exception(dataValidate); } else { dc.TechnologyMasters.InsertOnSubmit(technology); dc.SubmitChanges(); } }
public void insertTechnology(int id, string name, int cost) { DataClasses1DataContext dc = new DataClasses1DataContext(); TechnologyMaster technologyMaster = new TechnologyMaster(); technologyMaster.TechID = id; technologyMaster.TechName = name; technologyMaster.TechCost = cost; string checkColumn = checkCompulsoryTechnologyColumn(); if (checkColumn != "All field present") { throw new Exception(checkColumn); } dc.TechnologyMasters.InsertOnSubmit(technologyMaster); dc.SubmitChanges(); }
public void AddTechnology(TechnologyMaster technology) { try { string checkCompulsoryFields = DataLayerHelper.CheckCompulsoryTechnologyColumn(technology); if (checkCompulsoryFields != CMResources.AllFieldsPresent) { throw new Exception(checkCompulsoryFields); } dataContext.TechnologyMasters.InsertOnSubmit(technology); dataContext.SubmitChanges(); } catch (Exception ex) { throw ex; } }
public ActionResult Create([Bind(Include = "TechId,TechName")] TechnologyMaster technologyMaster) { try { var tech = db.TechnologyMasters.OrderByDescending(a => a.TechId).ToList(); int id = 1; if (tech.Count > 0) { id = tech[0].TechId + 1; } technologyMaster.TechId = id; db.TechnologyMasters.Add(technologyMaster); db.SaveChanges(); TempData["Message"] = "Technology Name Saved!"; } catch (Exception ex) { TempData["Error"] = ex.Message; } return(RedirectToAction("Index")); }