コード例 #1
0
        public Reader UpdateReader(Reader _reader)
        {
            try
            {
                using (var context = new LibrarySystemEntities())
                {
                    Reader oldreader = context.Readers.FirstOrDefault(c => c.ReaderId == _reader.ReaderId);
                    if (oldreader != null)
                    {
                        oldreader.FirstName = _reader.FirstName;
                        oldreader.LastName = _reader.LastName;
                        oldreader.Phone = _reader.Phone;
                        oldreader.Mail = _reader.Mail;

                        context.SaveChanges();
                        return oldreader;
                    }
                    return null;
                }
            }
            catch (Exception)
            {

                throw;
            }
        }
コード例 #2
0
        public MethodResponse UpdateReaderForWCF(Reader _reader)
        {
            MethodResponse methodresponse = new MethodResponse();
            try
            {
                Reader reader = UpdateReader(_reader);
                methodresponse.Type = MethodResponse.ResponseType.Succeed;
                methodresponse.ResultText = "Reader Updated";
                methodresponse.Object = reader;
            }
            catch (Exception ex)
            {
                CustomException custom_exception = new CustomException()
                {
                    Exception = ex,
                    ExceptionTime = DateTime.Now,
                    Parameters = "",
                    HelpLink = "",
                    User = "",
                    MethodName = "UpdateReaderForWCF"
                };
                CustomExceptionDB custom_exceptionDB = new CustomExceptionDB();
                bool isSaved = custom_exceptionDB.SaveException(custom_exception);
                if (isSaved == true)
                {
                    //..
                }
                methodresponse.Object = null;
                methodresponse.Type = MethodResponse.ResponseType.Error;
                methodresponse.ResultText = "An Error Occurred While Updating Reader";



            }
            return methodresponse;
        }
コード例 #3
0
        public Reader AddReader(Reader _reader)
        {
            try
            {
                using (var context = new LibrarySystemEntities())
                {
                    context.Readers.Add(_reader);

                    context.SaveChanges();
                    return _reader;
                }
            }
            catch (Exception)
            {

                throw;
            }
        }