Esempio n. 1
0
        public bool EditEmployeeAddress(EmployeeAddress model)
        {
            bool result = true;

            using (var context = new IMC2Context())
            {
                try
                {
                    var employeeAddressModel = context.EmployeeAddress.First(m => m.EmployeeAddressId == model.EmployeeAddressId);
                    employeeAddressModel.EmployeeAddressId = model.EmployeeAddressId;
                    employeeAddressModel.EmployeeId        = model.EmployeeId;
                    employeeAddressModel.AddressType       = model.AddressType;
                    employeeAddressModel.Address           = model.Address;
                    employeeAddressModel.Subdistrict       = model.Subdistrict;
                    employeeAddressModel.DistrictId        = model.DistrictId;
                    employeeAddressModel.ProvinceId        = model.ProvinceId;
                    employeeAddressModel.PostalCode        = model.PostalCode;
                    employeeAddressModel.PhoneNo           = model.PhoneNo;
                    employeeAddressModel.DateModified      = DateTime.Now;
                    employeeAddressModel.ModifiedBy        = model.ModifiedBy;
                    context.SaveChanges();
                }
                catch (Exception e)
                {
                    result = false;
                }
            }

            return(result);
        }
Esempio n. 2
0
        public bool AddEmployeeAddress(EmployeeAddress model)
        {
            bool result = true;

            using (var context = new IMC2Context())
            {
                try
                {
                    context.EmployeeAddress.Add(model);
                    context.SaveChanges();
                }
                catch (Exception e)
                {
                    result = false;
                }
            }

            return(result);
        }