//// GET: UserProfile/Create
        //public ActionResult Create()
        //{
        //    return View();
        //}

        //// POST: UserProfile/Create
        //// To protect from overposting attacks, please enable the specific properties you want to bind to, for
        //// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
        //[HttpPost]
        //[ValidateAntiForgeryToken]
        //public ActionResult Create([Bind(Include = "idNo,EIC,fullnameLast,birthdate,birthplace,Position,subPositionName,officeName,statusName,BATS_Area,WarmBody,Attnd_Scheme")] vUserProfile vUserProfile)
        //{
        //    if (ModelState.IsValid)
        //    {
        //        db.vUserProfile.Add(vUserProfile);
        //        db.SaveChanges();
        //        return RedirectToAction("Index");
        //    }

        //    return View(vUserProfile);
        //}

        // GET: UserProfile/Edit/5
        public ActionResult Edit(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            vUserProfile vUserProfile = db.vUserProfiles.FirstOrDefault(g => g.EIC == id);

            if (vUserProfile == null)
            {
                return(HttpNotFound());
            }

            var listEmpGroup = db.trefEmpGroups.ToList();

            ViewBag.listEmpGroup = listEmpGroup;

            var listStationArea = db.tAttStationAreas.ToList();

            ViewBag.listStationArea = listStationArea;

            var listAttendanceScheme = db.tAttSchemes.ToList();

            ViewBag.listAttendanceScheme = listAttendanceScheme;

            return(View(vUserProfile));
        }
Beispiel #2
0
        // GET: EditUserProfile/5
        public ActionResult EditUserProfile(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            vUserProfile vUserProfile = db.vUserProfiles.FirstOrDefault(g => g.EIC == id);

            if (vUserProfile == null)
            {
                ViewBag.ErrorMessage = "Record cannot be found.";
                return(RedirectToAction("Index"));

                return(HttpNotFound("Record cannot be found."));
            }

            var listEmpGroup = db.trefEmpGroups.ToList();

            ViewBag.listEmpGroup = listEmpGroup;

            var listStationArea = db.tAttStationAreas.ToList();

            ViewBag.listStationArea = listStationArea;

            var listAttendanceScheme = db.tAttSchemes.ToList();

            ViewBag.listAttendanceScheme = listAttendanceScheme;

            return(View(vUserProfile));
        }
        public ActionResult Edit(string EIC, string empGroupCode, string AreaID, string SchemeCode)
        {
            try
            {
                // fetch record
                if (db.tappEmpGroups.SingleOrDefault(r => r.EIC == EIC) == null)
                {
                    tappEmpGroup empGroup = new tappEmpGroup();
                    empGroup.EIC          = EIC;
                    empGroup.empGroupCode = empGroupCode;
                    db.tappEmpGroups.Add(empGroup);
                }
                else
                {
                    // update group code/name
                    tappEmpGroup empGroup = db.tappEmpGroups.Single(r => r.EIC == EIC);
                    empGroup.empGroupCode = empGroupCode;
                }

                if (db.tAttEmpSchemes.SingleOrDefault(r => r.EIC == EIC) == null)
                {
                    tAttEmpScheme attEmpScheme = new tAttEmpScheme();
                    attEmpScheme.EIC        = EIC;
                    attEmpScheme.SchemeCode = SchemeCode;
                    db.tAttEmpSchemes.Add(attEmpScheme);
                }
                else
                {
                    // update attendance scheme
                    tAttEmpScheme attndScheme = db.tAttEmpSchemes.Single(r => r.EIC == EIC);
                    attndScheme.SchemeCode = SchemeCode;
                }

                if (db.tAttEmpAreas.SingleOrDefault(r => r.EIC == EIC) == null)
                {
                    tAttEmpArea areaBATS = new tAttEmpArea();
                    areaBATS.EIC    = EIC;
                    areaBATS.AreaID = AreaID;
                    db.tAttEmpAreas.Add(areaBATS);
                }
                else
                {
                    // update attendance scheme
                    tAttEmpArea areaBATS = db.tAttEmpAreas.SingleOrDefault(r => r.EIC == EIC);
                    areaBATS.AreaID = AreaID;
                }

                // save all changes
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                ViewBag.ErrorMessage = ex.Message;
                vUserProfile vUserProfile = db.vUserProfiles.Single(r => r.EIC == EIC);
                return(View(vUserProfile));
            }
        }
Beispiel #4
0
        public VUserProfileDTO GetVUserProfileById(int?id)
        {
            if (!id.HasValue)
            {
                throw new ValidationException("The vUserProfile's id value is not set", String.Empty);
            }

            vUserProfile userProfile = database.vUserProfiles.Get(id.Value);

            return(_mapper.Map <vUserProfile, VUserProfileDTO>(userProfile));
        }
        // GET: UserProfile/Details/5
        public ActionResult Details(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            vUserProfile vUserProfile = db.vUserProfiles.FirstOrDefault(g => g.EIC == id);

            if (vUserProfile == null)
            {
                return(HttpNotFound());
            }
            return(View(vUserProfile));
        }
Beispiel #6
0
 public Task DeleteAsync(vUserProfile parameters)
 {
     throw new NotImplementedException();
 }
Beispiel #7
0
 public HashSet <string> DeleteValidation(vUserProfile parameters)
 {
     return(ValidationMessages);
 }
Beispiel #8
0
        public async Task UpdateAsync(vUserProfile entity)
        {
            await Uow.RegisterDirtyAsync(entity);

            await Uow.CommitAsync();
        }
Beispiel #9
0
 public HashSet <string> UpdateValidation(vUserProfile entity)
 {
     return(ValidationMessages);
 }
Beispiel #10
0
        public async Task AddAsync(vUserProfile entity)
        {
            await Uow.RegisterNewAsync(entity);

            await Uow.CommitAsync();
        }
Beispiel #11
0
 public async Task <object> GetBy(vUserProfile parameters)
 {
     //  throw new NotImplementedException();
     return(await Uow.Repository <vUserProfile>().SingleOrDefaultAsync(m => m.UserId == parameters.UserId));
 }
Beispiel #12
0
 public async Task <object> GetAsync(vUserProfile parameters)
 {
     //throw new NotImplementedException();
     return(await Uow.Repository <vUserProfile>().AllAsync());
 }