Пример #1
0
        public async Task <IActionResult> PutStateMaster(int id, StateMaster stateMaster)
        {
            if (id != stateMaster.StateId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Пример #2
0
        public async Task <IActionResult> PutAdminSetting(int id, AdminSetting adminSetting)
        {
            if (id != adminSetting.SettingId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Пример #3
0
        public async Task <IActionResult> PostTargetMatrix(string month, TargetMatrix targetMatrix)
        {
            try
            {
                if (targetMatrix.RowDataTargetMaster.Count > 0)
                {
                    DateTime selectedMonth = Convert.ToDateTime(month);
                    selectedMonth = new DateTime(selectedMonth.Year, selectedMonth.Month, 1);
                    int noOfWeek = GetWeekNumberOfMonth(selectedMonth);

                    List <TargetMaster> collTargetEntry = new List <TargetMaster>();
                    foreach (var item in targetMatrix.RowDataTargetMaster)
                    {
                        TargetMaster objTarget = new TargetMaster()
                        {
                            TagetId      = item.TagetId,
                            TelecallerId = item.TelecallerId,
                            MonthYear    = selectedMonth,
                            TargetWeek1  = item.TargetWeek1,
                            TargetWeek2  = item.TargetWeek2,
                            TargetWeek3  = item.TargetWeek3,
                            TargetWeek4  = item.TargetWeek4,
                            TargetWeek5  = item.TargetWeek5,
                            TargetWeek6  = item.TargetWeek6,
                        };
                        collTargetEntry.Add(objTarget);
                    }

                    _context.TargetMaster.UpdateRange(collTargetEntry);

                    await _context.SaveChangesAsync();

                    return(Ok("Target Created successfully!"));
                }
                else
                {
                    GenericMethods.Log(LogType.ErrorLog.ToString(), "PostTargetEntry: -target not exist");
                    return(NotFound("Target not found!"));
                }
            }
            catch (Exception ex)
            {
                GenericMethods.Log(LogType.ErrorLog.ToString(), "PostTargetEntry: " + ex.ToString());
                return(StatusCode(StatusCodes.Status500InternalServerError, ex));
            }
        }
        public async Task <IActionResult> PutUserMaster(Guid id, UserMaster userMaster)
        {
            if (id != userMaster.UserId)
            {
                GenericMethods.Log(LogType.ActivityLog.ToString(), "PutUserMaster: -user not matched");
                return(BadRequest("User not matched."));
            }

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

            try
            {
                GenericMethods.Log(LogType.ActivityLog.ToString(), "PutUserMaster: " + userMaster.Email + "-user updated successfully");
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UserMasterExists(id))
                {
                    GenericMethods.Log(LogType.ErrorLog.ToString(), "PutUserMaster: -get user failed");
                    return(NotFound("User not found"));
                }
                else
                {
                    GenericMethods.Log(LogType.ErrorLog.ToString(), "PutUserMaster: -get user failed");
                    throw;
                }
            }

            return(Ok(StatusCodes.Status200OK));
        }