Exemple #1
0
        public async Task <ActionResult <MasterLoginResult> > PostADMasterLogin(ADMasterLogin objADMasterLogin)
        {
            try
            {
                await _IMasterLoginInterface.InsertADMasterLogin(objADMasterLogin);

                return(CreatedAtAction("GetADMasterLogin", new { id = objADMasterLogin.MasterLoginId }, objADMasterLogin));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Exemple #2
0
        public async Task InsertADMasterEmployee(ADMasterEmployee objADMasterEmployee)
        {
            using (var transaction = _Context.Database.BeginTransaction())
            {
                try
                {
                    _Context.ADMasterEmployees.Add(objADMasterEmployee);
                    await _Context.SaveChangesAsync();

                    ADMasterLogin objADMasterLogin = new ADMasterLogin();
                    objADMasterLogin.MasterLoginId            = 0;
                    objADMasterLogin.MasterRegistrationTypeId = 3;
                    objADMasterLogin.MasterRegistrationId     = objADMasterEmployee.MasterEmployeeId;
                    objADMasterLogin.MasterProfileId          = 3;
                    objADMasterLogin.UserName         = objADMasterEmployee.Email;
                    objADMasterLogin.Password         = "******";
                    objADMasterLogin.VerificationCode = "";
                    objADMasterLogin.IsFirstLogin     = true;
                    objADMasterLogin.IsVerified       = false;
                    objADMasterLogin.IsActive         = false;

                    objADMasterLogin.EnterById    = objADMasterEmployee.EnterById;
                    objADMasterLogin.EnterDate    = objADMasterEmployee.EnterDate;
                    objADMasterLogin.ModifiedById = objADMasterEmployee.ModifiedById;
                    objADMasterLogin.ModifiedDate = objADMasterEmployee.ModifiedDate;

                    _Context.ADMasterLogins.Add(objADMasterLogin);
                    await _Context.SaveChangesAsync();

                    transaction.Commit();
                }
                catch (Exception ex)
                {
                    transaction.Rollback();

                    throw new Exception(ex.Message);
                }
            }
        }
        public async Task InsertADMasterLogin(ADMasterLogin objADMasterLogin)
        {
            using (var transaction = _Context.Database.BeginTransaction())
            {
                try
                {
                    //_Context.ADMasterEmployees.Add(objADMasterEmployee);
                    //await _Context.SaveChangesAsync();

                    //_Context.ADMasterLogins.Add(objADMasterLogin);
                    //await _Context.SaveChangesAsync();

                    transaction.Commit();
                }
                catch (Exception ex)
                {
                    transaction.Rollback();

                    throw new Exception(ex.Message);
                }
            }
        }
        public async Task UpdateADMasterLogin(ADMasterLogin objADMasterLogin)
        {
            using (var transaction = _Context.Database.BeginTransaction())
            {
                try
                {
                    _Context.Entry(objADMasterLogin).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                    await _Context.SaveChangesAsync();

                    var ADMasterEmployee = _Context.ADMasterEmployees.Where(a => a.MasterEmployeeId == objADMasterLogin.MasterRegistrationId).FirstOrDefault();
                    ADMasterEmployee.Email = objADMasterLogin.UserName;

                    _Context.Entry(ADMasterEmployee).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                    await _Context.SaveChangesAsync();

                    transaction.Commit();
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    throw new Exception(ex.Message);
                }
            }
        }
Exemple #5
0
        public async Task <ActionResult <MasterLoginResult> > PutADMasterLogin(long id, ADMasterLogin objADMasterLogin)
        {
            if (id != objADMasterLogin.MasterLoginId)
            {
                return(BadRequest());
            }


            try
            {
                await _IMasterLoginInterface.UpdateADMasterLogin(objADMasterLogin);

                return(_IMasterLoginInterface.GetADMasterLoginByID(id));
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!_IMasterLoginInterface.ADMasterLoginExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            return(NoContent());
        }