// // GET: /AWEmployees/Edit/5 public ActionResult Edit(int id) { DimEmployee dimemployee = db.DimEmployees.Find(id); ViewBag.ParentEmployeeKey = new SelectList(db.DimEmployees, "EmployeeKey", "EmployeeNationalIDAlternateKey", dimemployee.ParentEmployeeKey); return(View(dimemployee)); }
// // POST/GET: /AWEmployees/Filter public ActionResult Filter(DimEmployee dimemployee, bool salGreater, decimal?salary) { var model = from all in db.DimEmployees select all; // grab all records to display ViewBag.DepartmentName = new SelectList(GenDeptList()); // set dept name dropdownlist if (dimemployee.DepartmentName != null) // filter by dept, if specified { model = model.Where(x => x.DepartmentName == dimemployee.DepartmentName); } if (salary <= 0 || salary == null) // No salary filter { return(View("Index", model)); } else { if (salGreater) { model = model.Where(s => s.BaseRate >= salary); // Salary filters } else { model = model.Where(s => s.BaseRate <= salary); } return(View("Index", model)); } }
public ActionResult DeleteConfirmed(int id) { DimEmployee dimemployee = db.DimEmployees.Find(id); db.DimEmployees.Remove(dimemployee); db.SaveChanges(); return(RedirectToAction("Index")); }
/// <summary> /// Eliminar registro /// </summary> /// <param name="id"></param> /// <returns></returns> public IDimEmployeeDTO Delete(int id) { DimEmployee del = db.DimEmployee.Find(id); db.DimEmployee.Remove(del); db.SaveChanges(); return(del); }
/// <summary> /// Agregar registro /// </summary> /// <param name="datos"></param> /// <returns></returns> public IDimEmployeeDTO Create(IDimEmployeeDTO datos) { DimEmployee DimEmployeeParaGuardar = datos.MapperPruebas <IDimEmployeeDTO, DimEmployee>(); db.DimEmployee.Add(DimEmployeeParaGuardar); db.SaveChanges(); return(DimEmployeeParaGuardar.MapperPruebas <IDimEmployeeDTO, DimEmployee>()); }
public ActionResult Edit(DimEmployee dimemployee) { if (ModelState.IsValid) { db.Entry(dimemployee).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ParentEmployeeKey = new SelectList(db.DimEmployees, "EmployeeKey", "EmployeeNationalIDAlternateKey", dimemployee.ParentEmployeeKey); return(View(dimemployee)); }
public ActionResult Create(DimEmployee dimemployee) { if (ModelState.IsValid) { db.DimEmployees.Add(dimemployee); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ParentEmployeeKey = new SelectList(db.DimEmployees, "EmployeeKey", "EmployeeNationalIDAlternateKey", dimemployee.ParentEmployeeKey); return(View(dimemployee)); }
/// <summary> /// Metodo para agregar un empleado /// </summary> /// <param name="employee"></param> /// <returns></returns> public static async Task <DimEmployee> CreateAsync(DimEmployee employee) { string path = Constantes.urlDimEmployees; HttpResponseMessage response = await client.PostAsJsonAsync(path, employee); response.EnsureSuccessStatusCode(); employee = await response.Content.ReadAsAsync <DimEmployee>(); return(employee); }
// POST: odata/Employees public IHttpActionResult Post(DimEmployee dimEmployee) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.DimEmployees.Add(dimEmployee); db.SaveChanges(); return(Created(dimEmployee)); }
/// <summary> /// Metodo para obtener un Empleado a partir de su Id /// </summary> /// <param name="id"></param> /// <returns></returns> public static async Task <DimEmployee> GetAsync(int id) { string path = Constantes.urlDimEmployees + "/" + id; DimEmployee employee = null; HttpResponseMessage response = await client.GetAsync(path); if (response.IsSuccessStatusCode) { employee = await response.Content.ReadAsAsync <DimEmployee>(); } return(employee); }
// DELETE: odata/Employees(5) public IHttpActionResult Delete([FromODataUri] int key) { DimEmployee dimEmployee = db.DimEmployees.Find(key); if (dimEmployee == null) { return(NotFound()); } db.DimEmployees.Remove(dimEmployee); db.SaveChanges(); return(StatusCode(HttpStatusCode.NoContent)); }
/// <summary> /// Actualizar Registro /// </summary> /// <param name="datos"></param> /// <returns></returns> public IDimEmployeeDTO Update(IDimEmployeeDTO datos) { DimEmployee DimEmployeeEditar = db.DimEmployee.FirstOrDefault(c => c.EmployeeKey == datos.EmployeeKey); DimEmployee parametros = datos.MapperPruebasDetached(new DimEmployee()); if (DimEmployeeEditar == null) { return(new DimEmployee()); } //Mapeo para actualizar DimEmployeeEditar.ParentEmployeeKey = parametros.ParentEmployeeKey; DimEmployeeEditar.FirstName = parametros.FirstName; DimEmployeeEditar.LastName = parametros.LastName; DimEmployeeEditar.MiddleName = parametros.MiddleName; DimEmployeeEditar.Title = parametros.Title; DimEmployeeEditar.HireDate = parametros.HireDate; DimEmployeeEditar.BirthDate = parametros.BirthDate; DimEmployeeEditar.EmailAddress = parametros.EmailAddress; DimEmployeeEditar.Phone = parametros.Phone; DimEmployeeEditar.MaritalStatus = parametros.MaritalStatus; DimEmployeeEditar.EmergencyContactName = parametros.EmergencyContactName; DimEmployeeEditar.EmergencyContactPhone = parametros.EmergencyContactPhone; DimEmployeeEditar.SalariedFlag = parametros.SalariedFlag; DimEmployeeEditar.Gender = parametros.Gender; DimEmployeeEditar.PayFrequency = parametros.PayFrequency; DimEmployeeEditar.BaseRate = parametros.BaseRate; DimEmployeeEditar.VacationHours = parametros.VacationHours; DimEmployeeEditar.CurrentFlag = parametros.CurrentFlag; DimEmployeeEditar.SalesPersonFlag = parametros.SalesPersonFlag; DimEmployeeEditar.DepartmentName = parametros.DepartmentName; DimEmployeeEditar.StartDate = parametros.StartDate; DimEmployeeEditar.EndDate = parametros.EndDate; DimEmployeeEditar.Status = parametros.Status; DimEmployeeEditar.ImageUrl = parametros.ImageUrl; DimEmployeeEditar.ProfileUrl = parametros.ProfileUrl; DimEmployeeEditar.ETLLoadID = parametros.ETLLoadID; DimEmployeeEditar.LoadDate = parametros.LoadDate; DimEmployeeEditar.UpdateDate = parametros.UpdateDate; if (db.SaveChanges() <= 0) { //error } return(DimEmployeeEditar); }
public async Task <ActionResult> Create([Bind(Include = "EmployeeKey,ParentEmployeeKey,FirstName,LastName,MiddleName,Title,HireDate,BirthDate,EmailAddress,Phone,MaritalStatus,EmergencyContactName,EmergencyContactPhone,SalariedFlag,Gender,PayFrequency,BaseRate,VacationHours,CurrentFlag,SalesPersonFlag,DepartmentName,StartDate,EndDate,Status,ImageUrl,ProfileUrl,ETLLoadID,LoadDate,UpdateDate")] DimEmployee dimEmployee) { if (ModelState.IsValid) { DimEmployee respuesta = await DimEmployeesClient.CreateAsync(dimEmployee); if (respuesta != null) { return(RedirectToAction("Index")); } } //ViewBag.ParentEmployeeKey = new SelectList(db.DimEmployee, "EmployeeKey", "FirstName", dimEmployee.ParentEmployeeKey); return(View(dimEmployee)); }
static void Main(string[] args) { AdventureWorksDW2017Context context = new AdventureWorksDW2017Context(); DimEmployee firstEmployee = context.DimEmployee.FirstOrDefault(); Console.WriteLine($"Login ID : {firstEmployee.LoginId}"); context.DimEmployee.Add(new DimEmployee { FirstName = "Uğur", LastName = "Demir", NameStyle = false, SalariedFlag = false, LoginId = "adventure-works\\uurdemir" }); context.SaveChanges(); }
public IActionResult getList() { string sql = @"select de.FirstName, de.LastName, de.MiddleName, de.NameStyle, de.Title, de.BirthDate, de.EmailAddress, de.Phone FROM dbo.DimEmployee de WHERE de.CurrentFlag = @CurrentFlag"; var listParameter = new List <SqlParameter>(); SqlParameter param = new SqlParameter(); param.ParameterName = "@CurrentFlag"; param.Value = 1; listParameter.Add(param); var datas = SqlAccess.FillDataset(sql, listParameter.ToArray()); int total = datas.Rows.Count; List <DimEmployee> EmployeeList = new List <DimEmployee>(); for (int i = 0; i < total; i++) { DimEmployee item = new DimEmployee(); item.FirstName = datas.Rows[i]["FirstName"].ToString(); item.LastName = datas.Rows[i]["LastName"].ToString(); item.MiddleName = datas.Rows[i]["MiddleName"].ToString(); item.NameStyle = datas.Rows[i]["NameStyle"].ToString(); item.Title = datas.Rows[i]["Title"].ToString(); item.BirthDate = datas.Rows[i]["BirthDate"].ToString(); item.EmailAddress = datas.Rows[i]["EmailAddress"].ToString(); item.Phone = datas.Rows[i]["Phone"].ToString(); EmployeeList.Add(item); } var obj = new { totalRow = total, datas = EmployeeList }; return(Json(obj)); }
// PUT: odata/Employees(5) public IHttpActionResult Put([FromODataUri] int key, Delta <DimEmployee> patch) { Validate(patch.GetInstance()); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } DimEmployee dimEmployee = db.DimEmployees.Find(key); if (dimEmployee == null) { return(NotFound()); } patch.Put(dimEmployee); try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!DimEmployeeExists(key)) { return(NotFound()); } else { throw; } } return(Updated(dimEmployee)); }
// // GET: /AWEmployees/Delete/5 public ActionResult Delete(int id) { DimEmployee dimemployee = db.DimEmployees.Find(id); return(View(dimemployee)); }
// // GET: /AWEmployees/Details/5 public ViewResult Details(int id) { DimEmployee dimemployee = db.DimEmployees.Find(id); return(View(dimemployee)); }