public async Task <ActionResult <bool> > UpdateCardDetails([FromBody] List <MyCard> myCards)
        {
            bool result = true;

            using (var trans = _context.Database.BeginTransaction())
            {
                try
                {
                    foreach (var item in myCards)
                    {
                        var _card = _context.MyCards.SingleOrDefault(d => d.MemberID == item.MemberID && d.ClientSpaceFloorPlanID == item.ClientSpaceFloorPlanID && d.ClientSpaceSeatID == item.ClientSpaceSeatID);
                        if (_card == null)
                        {
                            _context.Add(item);
                            await _context.SaveChangesAsync();
                        }
                        else
                        {
                            _context.Entry(_card).State = EntityState.Modified;
                            await _context.SaveChangesAsync();
                        }
                    }
                    trans.Commit();
                }
                catch (Exception err)
                {
                    trans.Rollback();
                    result = false;
                }
            }
            return(result);
        }
        public async Task <ActionResult <bool> > UpdateMemberMaster(int MemberID, [FromBody]  MemberMaster MemberMaster)
        {
            bool result = true;

            if (MemberID != MemberMaster.MemberID || MemberMaster == null)
            {
                return(BadRequest());
            }

            _context.Entry(MemberMaster).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MemberMasterExists(MemberID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            //return NoContent();
            return(result);
        }
        public async Task <ActionResult <bool> > UpdateUserLogin(int UserID, [FromBody] UserLogin userLogin)
        {
            if (UserID != userLogin.UserID || userLogin == null)
            {
                return(BadRequest());
            }

            _context.Entry(userLogin).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UserLoginExists(UserID))
                {
                    //return NotFound();
                    return(false);
                }
                else
                {
                    throw;
                }
            }

            //return NoContent();
            return(true);
        }
Example #4
0
        public async Task <IActionResult> PutFacility(int id, FacilityMaster facility)
        {
            if (id != facility.FacilityID)
            {
                return(BadRequest());
            }

            _context.Entry(facility).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!FacilityExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #5
0
        public async Task <IActionResult> UpdateLead(int LeadID, [FromBody] Lead lead)
        {
            if (LeadID != lead.LeadID || lead == null)
            {
                return(BadRequest());
            }

            _context.Entry(lead).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LeadExists(LeadID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <ActionResult <bool> > UploadAttendance([FromBody] List <Attendance> attendance, int MemberID)
        {
            bool result = true;

            using (var trans = _context.Database.BeginTransaction())
            {
                try
                {
                    try
                    {
                        foreach (var atten in attendance)
                        {
                            var _atten = _context.Attendance.SingleOrDefault(d => d.MemberID == MemberID && d.EmpCode == atten.EmpCode && d.AttendanceDate == atten.AttendanceDate);
                            if (_atten != null)
                            {
                                _atten.InTime  = atten.InTime;
                                _atten.OutTime = atten.OutTime;
                                _context.Entry(_atten).State = EntityState.Modified;
                            }
                            else
                            {
                                _context.Attendance.Add(atten);
                            }
                        }

                        await _context.SaveChangesAsync();

                        trans.Commit();
                    }
                    catch (DbUpdateConcurrencyException err)
                    {
                        trans.Rollback();
                        result = false;
                    }
                }
                catch (Exception err)
                {
                    trans.Rollback();
                    result = false;
                }
            }
            return(result);
        }
        public async Task <ActionResult <bool> > AddEditEmployee([FromBody] EmployeeMaster employee)
        {
            bool result = true;

            using (var trans = _context.Database.BeginTransaction())
            {
                try
                {
                    try
                    {
                        var emp = _context.Employees.SingleOrDefault(d => d.MemberID == employee.MemberID && d.EmpCode == employee.EmpCode);

                        if (emp != null)
                        {
                            emp.ModifiedDateTime      = DateTime.Now;
                            _context.Entry(emp).State = EntityState.Modified;
                        }
                        else
                        {
                            employee.CreatedDateTime = DateTime.Now;
                            _context.Employees.Add(employee);
                        }
                        await _context.SaveChangesAsync();

                        trans.Commit();
                    }
                    catch (DbUpdateConcurrencyException err)
                    {
                        trans.Rollback();
                        result = false;
                    }
                }
                catch (Exception err)
                {
                    trans.Rollback();
                    result = false;
                }
            }
            return(result);
        }
Example #8
0
        public async Task <ActionResult <bool> > AddEditHoliday([FromBody] HolidayMaster holiday)
        {
            bool result = true;

            using (var trans = _context.Database.BeginTransaction())
            {
                try
                {
                    try
                    {
                        if (holiday.HolidayID > 0)
                        {
                            _context.Entry(holiday).State = EntityState.Modified;
                        }
                        else
                        {
                            _context.Holidays.Add(holiday);
                        }
                        await _context.SaveChangesAsync();

                        trans.Commit();
                    }
                    catch (DbUpdateConcurrencyException err)
                    {
                        trans.Rollback();
                        result = false;
                    }
                }
                catch (Exception err)
                {
                    trans.Rollback();
                    result = false;
                }
            }
            return(result);
        }